From 599220a931e895e6b21b8dfe3dff90b63f12e0c8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 19 Nov 2020 09:15:16 +1100 Subject: [PATCH] Fixes for custom SQL queries - Don't use double quotes! - NO NO NO! - Single quotes only --- InvenTree/company/migrations/0026_auto_20201110_1011.py | 6 +++--- InvenTree/part/migrations/0056_auto_20201110_1125.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/InvenTree/company/migrations/0026_auto_20201110_1011.py b/InvenTree/company/migrations/0026_auto_20201110_1011.py index 24fac6f52d..1202fbe7f7 100644 --- a/InvenTree/company/migrations/0026_auto_20201110_1011.py +++ b/InvenTree/company/migrations/0026_auto_20201110_1011.py @@ -67,7 +67,7 @@ def migrate_currencies(apps, schema_editor): currency_code = remap.get(currency_id, 'USD') # Update the currency code - response = cursor.execute(f'UPDATE part_supplierpricebreak set price_currency= "{currency_code}" where id={pk};') + response = cursor.execute(f"UPDATE part_supplierpricebreak set price_currency= '{currency_code}' where id={pk};") count += 1 @@ -105,7 +105,7 @@ def reverse_currencies(apps, schema_editor): # For each currency code in use, check if we have a matching Currency object for code in codes_in_use: - response = cursor.execute(f'SELECT id, suffix from common_currency where suffix="{code}";') + response = cursor.execute(f"SELECT id, suffix from common_currency where suffix='{code}';") row = response.fetchone() if row is not None: @@ -133,7 +133,7 @@ def reverse_currencies(apps, schema_editor): # Update the table to point to the Currency objects print(f"Currency {suffix} -> pk {pk}") - response = cursor.execute(f'UPDATE part_supplierpricebreak set currency_id={pk} where price_currency="{suffix}";') + response = cursor.execute(f"UPDATE part_supplierpricebreak set currency_id={pk} where price_currency='{suffix}';") class Migration(migrations.Migration): diff --git a/InvenTree/part/migrations/0056_auto_20201110_1125.py b/InvenTree/part/migrations/0056_auto_20201110_1125.py index dff86173b6..3e4572b518 100644 --- a/InvenTree/part/migrations/0056_auto_20201110_1125.py +++ b/InvenTree/part/migrations/0056_auto_20201110_1125.py @@ -67,7 +67,7 @@ def migrate_currencies(apps, schema_editor): currency_code = remap.get(currency_id, 'USD') # Update the currency code - response = cursor.execute(f'UPDATE part_partsellpricebreak set price_currency= "{currency_code}" where id={pk};') + response = cursor.execute(f"UPDATE part_partsellpricebreak set price_currency='{currency_code}' where id={pk};") count += 1 @@ -105,7 +105,7 @@ def reverse_currencies(apps, schema_editor): # For each currency code in use, check if we have a matching Currency object for code in codes_in_use: - response = cursor.execute(f'SELECT id, suffix from common_currency where suffix="{code}";') + response = cursor.execute(f"SELECT id, suffix from common_currency where suffix='{code}';") row = response.fetchone() if row is not None: @@ -120,7 +120,7 @@ def reverse_currencies(apps, schema_editor): print(f"Creating new Currency object for {code}") # Construct a query to create a new Currency object - query = f'INSERT into common_currency (symbol, suffix, description, value, base) VALUES ("$", "{code}", "{description}", 1.0, False);' + query = f"INSERT into common_currency (symbol, suffix, description, value, base) VALUES ('$', '{code}', '{description}', 1.0, False);" response = cursor.execute(query) @@ -133,7 +133,7 @@ def reverse_currencies(apps, schema_editor): # Update the table to point to the Currency objects print(f"Currency {suffix} -> pk {pk}") - response = cursor.execute(f'UPDATE part_partsellpricebreak set currency_id={pk} where price_currency="{suffix}";') + response = cursor.execute(f"UPDATE part_partsellpricebreak set currency_id={pk} where price_currency='{suffix}';") class Migration(migrations.Migration):