From c4e9e4e646d49f9d93baa7a1df8c53a1c6b7d941 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Wed, 4 Mar 2026 23:55:00 +0100 Subject: [PATCH] fix(seed): use SQLAlchemy .is_not(None) instead of Python 'is not None' in queries 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 --- scripts/seed/seed_demo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/seed/seed_demo.py b/scripts/seed/seed_demo.py index ba7b4d61..a1cefd3f 100644 --- a/scripts/seed/seed_demo.py +++ b/scripts/seed/seed_demo.py @@ -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}")