Unverified Commit 141beae9 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

fix: use all values in replace statement

parent 45a1b23a
Pipeline #21774 passed with stages
in 1 minute and 53 seconds
...@@ -43,10 +43,11 @@ class Indexer: ...@@ -43,10 +43,11 @@ class Indexer:
""" """
db_values = [record[f] for f in fields if f in record and record[f]] db_values = [record[f] for f in fields if f in record and record[f]]
db_values.extend([record[f] for f in fields if f != 'sig' and f in record and record[f]]) db_values.extend([record[f] for f in fields if f != 'sig' and f in record and record[f]])
key_value = ", ".join([f"{f}=%s" for f in fields db_fields = ','.join([f for f in fields if f in record and record[f]])
if f != 'sig' and f in record and record[f]]) db_value_placeholders = ', '.join(['%s' for f in fields if f in record and record[f]])
# noinspection SqlNoDataSourceInspection # noinspection SqlNoDataSourceInspection
sql = 'REPLACE INTO {} SET {}'.format(table_name, key_value) sql = 'REPLACE INTO {} ({}) VALUES ({})'.format(
table_name, db_fields, db_value_placeholders)
return sql, tuple(db_values) return sql, tuple(db_values)
def insert_in_db(self, record) -> (bool, str): def insert_in_db(self, record) -> (bool, str):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment