mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-31 15:32:27 +00:00
test(stock): use db-agnostic index introspection in Bin index test
test_index_exists used `frappe.db.sql("show index from tabBin ...")`. "SHOW INDEX"
is MySQL-only syntax and errors on Postgres (syntax error at "from"), so the test
could not run there. Use the db-agnostic frappe.db.has_index("tabBin",
"unique_item_warehouse") instead.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,6 @@ class TestBin(ERPNextTestSuite):
|
|||||||
self.assertEqual(bin.item_code, item_code)
|
self.assertEqual(bin.item_code, item_code)
|
||||||
|
|
||||||
def test_index_exists(self):
|
def test_index_exists(self):
|
||||||
indexes = frappe.db.sql("show index from tabBin where Non_unique = 0", as_dict=1)
|
# has_index is db-agnostic; raw "SHOW INDEX" is MySQL-only and errors on Postgres
|
||||||
if not any(index.get("Key_name") == "unique_item_warehouse" for index in indexes):
|
if not frappe.db.has_index("tabBin", "unique_item_warehouse"):
|
||||||
self.fail("Expected unique index on item-warehouse")
|
self.fail("Expected unique index on item-warehouse")
|
||||||
|
|||||||
Reference in New Issue
Block a user