Skip to content

Commit

Permalink
doc(copy): handle PGSQL complex ON CONFLICT target expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmirloup committed May 17, 2024
1 parent 234e95f commit 42e9b59
Showing 1 changed file with 11 additions and 8 deletions.
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 |

0 comments on commit 42e9b59

Please sign in to comment.