mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
Fix for SQL cursor query
- What works in SQLite don't necessarily fly with the big boys
This commit is contained in:
parent
5567ad07fd
commit
fc89501a62
@ -27,11 +27,13 @@ def migrate_currencies(apps, schema_editor):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
# The 'suffix' field denotes the currency code
|
# The 'suffix' field denotes the currency code
|
||||||
response = cursor.execute('SELECT id, suffix, description from common_currency;').fetchall()
|
response = cursor.execute('SELECT id, suffix, description from common_currency;')
|
||||||
|
|
||||||
|
results = cursor.fetchall()
|
||||||
|
|
||||||
remap = {}
|
remap = {}
|
||||||
|
|
||||||
for index, row in enumerate(response):
|
for index, row in enumerate(results):
|
||||||
pk, suffix, description = row
|
pk, suffix, description = row
|
||||||
|
|
||||||
suffix = suffix.strip().upper()
|
suffix = suffix.strip().upper()
|
||||||
@ -49,11 +51,13 @@ def migrate_currencies(apps, schema_editor):
|
|||||||
remap[pk] = suffix
|
remap[pk] = suffix
|
||||||
|
|
||||||
# Now iterate through each SupplierPriceBreak and update the rows
|
# Now iterate through each SupplierPriceBreak and update the rows
|
||||||
response = cursor.execute('SELECT id, cost, currency_id, price, price_currency from part_supplierpricebreak;').fetchall()
|
response = cursor.execute('SELECT id, cost, currency_id, price, price_currency from part_supplierpricebreak;')
|
||||||
|
|
||||||
|
results = cursor.fetchall()
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
for index, row in enumerate(response):
|
for index, row in enumerate(results):
|
||||||
pk, cost, currency_id, price, price_currency = row
|
pk, cost, currency_id, price, price_currency = row
|
||||||
|
|
||||||
# Copy the 'cost' field across to the 'price' field
|
# Copy the 'cost' field across to the 'price' field
|
||||||
@ -82,11 +86,13 @@ def reverse_currencies(apps, schema_editor):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
# Extract a list of currency codes which are in use
|
# Extract a list of currency codes which are in use
|
||||||
response = cursor.execute(f'SELECT id, price, price_currency from part_supplierpricebreak;').fetchall()
|
response = cursor.execute(f'SELECT id, price, price_currency from part_supplierpricebreak;')
|
||||||
|
|
||||||
|
results = cursor.fetchall()
|
||||||
|
|
||||||
codes_in_use = set()
|
codes_in_use = set()
|
||||||
|
|
||||||
for index, row in enumerate(response):
|
for index, row in enumerate(results):
|
||||||
pk, price, code = row
|
pk, price, code = row
|
||||||
|
|
||||||
codes_in_use.add(code)
|
codes_in_use.add(code)
|
||||||
|
@ -27,11 +27,13 @@ def migrate_currencies(apps, schema_editor):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
# The 'suffix' field denotes the currency code
|
# The 'suffix' field denotes the currency code
|
||||||
response = cursor.execute('SELECT id, suffix, description from common_currency;').fetchall()
|
response = cursor.execute('SELECT id, suffix, description from common_currency;')
|
||||||
|
|
||||||
|
results = cursor.fetchall()
|
||||||
|
|
||||||
remap = {}
|
remap = {}
|
||||||
|
|
||||||
for index, row in enumerate(response):
|
for index, row in enumerate(results):
|
||||||
pk, suffix, description = row
|
pk, suffix, description = row
|
||||||
|
|
||||||
suffix = suffix.strip().upper()
|
suffix = suffix.strip().upper()
|
||||||
@ -49,11 +51,13 @@ def migrate_currencies(apps, schema_editor):
|
|||||||
remap[pk] = suffix
|
remap[pk] = suffix
|
||||||
|
|
||||||
# Now iterate through each PartSellPriceBreak and update the rows
|
# Now iterate through each PartSellPriceBreak and update the rows
|
||||||
response = cursor.execute('SELECT id, cost, currency_id, price, price_currency from part_partsellpricebreak;').fetchall()
|
response = cursor.execute('SELECT id, cost, currency_id, price, price_currency from part_partsellpricebreak;')
|
||||||
|
|
||||||
|
results = cursor.fetchall()
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
for index, row in enumerate(response):
|
for index, row in enumerate(results):
|
||||||
pk, cost, currency_id, price, price_currency = row
|
pk, cost, currency_id, price, price_currency = row
|
||||||
|
|
||||||
# Copy the 'cost' field across to the 'price' field
|
# Copy the 'cost' field across to the 'price' field
|
||||||
@ -82,11 +86,13 @@ def reverse_currencies(apps, schema_editor):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
# Extract a list of currency codes which are in use
|
# Extract a list of currency codes which are in use
|
||||||
response = cursor.execute(f'SELECT id, price, price_currency from part_partsellpricebreak;').fetchall()
|
response = cursor.execute(f'SELECT id, price, price_currency from part_partsellpricebreak;')
|
||||||
|
|
||||||
|
results = cursor.fetchall()
|
||||||
|
|
||||||
codes_in_use = set()
|
codes_in_use = set()
|
||||||
|
|
||||||
for index, row in enumerate(response):
|
for index, row in enumerate(results):
|
||||||
pk, price, code = row
|
pk, price, code = row
|
||||||
|
|
||||||
codes_in_use.add(code)
|
codes_in_use.add(code)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user