2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 21:15:41 +00:00

Fixes for custom SQL queries

- Don't use double quotes!
- NO NO NO!
- Single quotes only
This commit is contained in:
Oliver Walters
2020-11-19 09:15:16 +11:00
parent 0594ebaef7
commit 599220a931
2 changed files with 7 additions and 7 deletions

View File

@ -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):