mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 13:28:49 +00:00
Migration fix (response is different for postgresql)
This commit is contained in:
parent
793e5b820e
commit
0e246a7fdf
@ -23,7 +23,7 @@ def reverse_association(apps, schema_editor):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
response = cursor.execute("select id, MPN from part_supplierpart;")
|
response = cursor.execute("select id, MPN from part_supplierpart;")
|
||||||
supplier_parts = response.fetchall()
|
supplier_parts = cursor.fetchall()
|
||||||
|
|
||||||
# Exit if there are no SupplierPart objects
|
# Exit if there are no SupplierPart objects
|
||||||
# This crucial otherwise the unit test suite fails!
|
# This crucial otherwise the unit test suite fails!
|
||||||
@ -42,7 +42,7 @@ def reverse_association(apps, schema_editor):
|
|||||||
|
|
||||||
manufacturer_id = None
|
manufacturer_id = None
|
||||||
|
|
||||||
row = response.fetchone()
|
row = cursor.fetchone()
|
||||||
|
|
||||||
if len(row) > 0:
|
if len(row) > 0:
|
||||||
try:
|
try:
|
||||||
@ -59,7 +59,7 @@ def reverse_association(apps, schema_editor):
|
|||||||
# Now extract the "name" for the manufacturer
|
# Now extract the "name" for the manufacturer
|
||||||
response = cursor.execute(f"SELECT name from company_company where id={manufacturer_id};")
|
response = cursor.execute(f"SELECT name from company_company where id={manufacturer_id};")
|
||||||
|
|
||||||
row = response.fetchone()
|
row = cursor.fetchone()
|
||||||
|
|
||||||
name = row[0]
|
name = row[0]
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ def associate_manufacturers(apps, schema_editor):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
response = cursor.execute("select id, MPN from part_supplierpart;")
|
response = cursor.execute("select id, MPN from part_supplierpart;")
|
||||||
supplier_parts = response.fetchall()
|
supplier_parts = cursor.fetchall()
|
||||||
|
|
||||||
# Exit if there are no SupplierPart objects
|
# Exit if there are no SupplierPart objects
|
||||||
# This crucial otherwise the unit test suite fails!
|
# This crucial otherwise the unit test suite fails!
|
||||||
@ -166,7 +166,7 @@ def associate_manufacturers(apps, schema_editor):
|
|||||||
|
|
||||||
# Extract the company back from the database
|
# Extract the company back from the database
|
||||||
response = cursor.execute(f"select id from company_company where name='{company_name}';")
|
response = cursor.execute(f"select id from company_company where name='{company_name}';")
|
||||||
row = response.fetchone()
|
row = cursor.fetchone()
|
||||||
manufacturer_id = int(row[0])
|
manufacturer_id = int(row[0])
|
||||||
|
|
||||||
# Map both names to the same company
|
# Map both names to the same company
|
||||||
@ -318,7 +318,7 @@ def associate_manufacturers(apps, schema_editor):
|
|||||||
# Extract all SupplierPart objects from the database
|
# Extract all SupplierPart objects from the database
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
response = cursor.execute("select id, MPN, SKU, manufacturer_id, manufacturer_name from part_supplierpart;")
|
response = cursor.execute("select id, MPN, SKU, manufacturer_id, manufacturer_name from part_supplierpart;")
|
||||||
results = response.fetchall()
|
results = cursor.fetchall()
|
||||||
|
|
||||||
part_count = len(results)
|
part_count = len(results)
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ def reverse_currencies(apps, schema_editor):
|
|||||||
# For each currency code in use, check if we have a matching Currency object
|
# For each currency code in use, check if we have a matching Currency object
|
||||||
for code in codes_in_use:
|
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()
|
row = cursor.fetchone()
|
||||||
|
|
||||||
if row is not None:
|
if row is not None:
|
||||||
# A match exists!
|
# A match exists!
|
||||||
|
@ -106,7 +106,7 @@ def reverse_currencies(apps, schema_editor):
|
|||||||
# For each currency code in use, check if we have a matching Currency object
|
# For each currency code in use, check if we have a matching Currency object
|
||||||
for code in codes_in_use:
|
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()
|
row = cursor.fetchone()
|
||||||
|
|
||||||
if row is not None:
|
if row is not None:
|
||||||
# A match exists!
|
# A match exists!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user