fix(seed): use SQLAlchemy .is_not(None) instead of Python 'is not None' in queries
Some checks failed
CI / ruff (push) Successful in 9s
CI / pytest (push) Failing after 49m50s
CI / validate (push) Successful in 24s
CI / dependency-scanning (push) Successful in 28s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped

The reset_all_data() function used `ContentPage.store_id is not None` which
is a Python identity check (always True), causing it to delete ALL content
pages including platform defaults. Same bug in print_summary() caused the
count to always show 0 platform pages. Fixed both to use proper SQLAlchemy
.is_(None) / .is_not(None) syntax.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 23:55:00 +01:00
parent 8c449d7baa
commit c4e9e4e646

View File

@@ -707,7 +707,7 @@ def reset_all_data(db: Session):
for table in tables_to_clear:
if table == ContentPage:
# Only delete store content pages, keep platform defaults
db.execute(delete(ContentPage).where(ContentPage.store_id is not None))
db.execute(delete(ContentPage).where(ContentPage.store_id.is_not(None)))
else:
db.execute(delete(table))
@@ -1416,8 +1416,8 @@ def print_summary(db: Session):
team_member_count = db.query(StoreUser).count()
customer_count = db.query(Customer).count()
product_count = db.query(Product).count()
platform_pages = db.query(ContentPage).filter(ContentPage.store_id is None).count()
store_pages = db.query(ContentPage).filter(ContentPage.store_id is not None).count()
platform_pages = db.query(ContentPage).filter(ContentPage.store_id.is_(None)).count()
store_pages = db.query(ContentPage).filter(ContentPage.store_id.is_not(None)).count()
print("\n📊 Database Status:")
print(f" Merchants: {merchant_count}")