From 42e9b595daf93d54a614d3a2dee2a6ed808237eb Mon Sep 17 00:00:00 2001 From: Lucas Mirloup <97196064+lucasmirloup@users.noreply.github.com> Date: Fri, 17 May 2024 18:48:24 +0200 Subject: [PATCH] doc(copy): handle PGSQL complex ON CONFLICT target expressions --- docs/configure/copy.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/configure/copy.md b/docs/configure/copy.md index 91ec204..d42ecc6 100644 --- a/docs/configure/copy.md +++ b/docs/configure/copy.md @@ -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 @@ -84,4 +87,4 @@ Three strategies are available: | `` | ✅ | | Replace `` with the name of the column to be created | | `property` | ➖ | string[] | 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 | \ No newline at end of file +| `update_sql` | ➖ (`null`) | string | SQL statement `UPDATE |