Skip to content

Commit e73e082

Browse files
committed
Make the sql_template decision more debugger-friendly.
1 parent 2f4b442 commit e73e082

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

psqlextra/compiler.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,17 @@ def _rewrite_insert_update(self, sql, params, returning):
105105

106106
index_predicate = self.query.index_predicate
107107

108-
sql_template = \
109-
(
110-
'{insert} ON CONFLICT {conflict_target} WHERE {index_predicate} DO UPDATE'
111-
' SET {update_columns} RETURNING {returning}'
112-
) if index_predicate else (
113-
'{insert} ON CONFLICT {conflict_target} DO UPDATE'
114-
' SET {update_columns} RETURNING {returning}'
108+
sql_template = (
109+
'{insert} ON CONFLICT {conflict_target} DO UPDATE '
110+
'SET {update_columns} RETURNING {returning}'
111+
)
112+
113+
if index_predicate:
114+
sql_template = (
115+
'{insert} ON CONFLICT {conflict_target} WHERE {index_predicate} DO UPDATE '
116+
'SET {update_columns} RETURNING {returning}'
115117
)
118+
116119
return (
117120
sql_template.format(
118121
insert=sql,

0 commit comments

Comments
 (0)