Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(copy): handle PGSQL complex ON CONFLICT target expressions #11

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions docs/configure/copy.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ Three strategies are available:
distinct: true
joins: INNER JOIN table ON (table.email = temp.email_commercial)
conflict_target: email
# OR
conflict_target:
sql: "(email)"
non_updateable_fields: ["email", "username"]
```

| Name | Mandatory (default) | Type | |
| ----------------------- |-----------------------|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `copy_condition` | ➖ | string | SQL condition to insert in the insertion query (omit `WHERE`) |
| `distinct` | ➖ (`false`) | boolean | Inserts `DISTINCT` in the selection query |
| `joins` | ➖ | string | SQL joins to be inserted in the selection query |
| `conflict_target` | ➖ | string | (PostgreSQL AND `strategy=insert_or_update|insert_ignore` only, mandatory if `strategy=insert_or_update`). Column index(es) to be used in `ON CONFLICT`, see [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-insert.html#SQL-ON-CONFLICT) |
| `non_updateable_fields` | ➖ (`[]`) | string[] | List of fields not to be updated during imports |
| Name | Mandatory (default) | Type | |
|-------------------------|---------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `copy_condition` | ➖ | string | SQL condition to insert in the insertion query (omit `WHERE`) |
| `distinct` | ➖ (`false`) | boolean | Inserts `DISTINCT` in the selection query |
| `joins` | ➖ | string | SQL joins to be inserted in the selection query |
| `conflict_target` | ➖ | string; ['sql': string] | (PostgreSQL AND `strategy=insert_or_update|insert_ignore` only, mandatory if `strategy=insert_or_update`). Column index(es) to be used in `ON CONFLICT`, see [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-insert.html#SQL-ON-CONFLICT). When passed as a string, parentheses are added around the value. When passed in the 'sql' array key, the value is inserted as-is. |
| `non_updateable_fields` | ➖ (`[]`) | string[] | List of fields not to be updated during imports |

## mapping

Expand Down Expand Up @@ -84,4 +87,4 @@ Three strategies are available:
| `<name>` | ✅ | | Replace `<name>` with the name of the column to be created |
| `property` | ➖ | string[] &#124; string | List of columns in the application in which to insert the data |
| `sql` | ➖ (`null`) | boolean | SQL statement of the value to be inserted in the target column |
| `update_sql` | ➖ (`null`) | string | SQL statement `UPDATE |
| `update_sql` | ➖ (`null`) | string | SQL statement `UPDATE |