From 0e3c9fb52ec43fde15090199f22ac4db2913173f Mon Sep 17 00:00:00 2001 From: Barcode Betty Date: Sat, 23 May 2026 23:07:28 +0000 Subject: [PATCH] Fix: strip PostgreSQL server_default from email_inbound_token for SQLite The email_inbound_token column uses a PostgreSQL-only server_default (gen_random_bytes/encode/trim) that SQLite cannot parse. Strip the server_default before metadata.create_all() in both the sync engine and async db_engine fixtures so tests run against SQLite. Co-Authored-By: Paperclip --- tests/conftest.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index baa3c87..5bd4e67 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -53,6 +53,10 @@ def disable_rate_limiting(): def engine(): """Sync in-memory SQLite engine for model unit tests.""" eng = create_engine("sqlite:///:memory:") + from cartsnitch_api.models.user import User + + col = User.__table__.columns["email_inbound_token"] + col.server_default = None Base.metadata.create_all(eng) yield eng eng.dispose() @@ -77,6 +81,9 @@ async def db_engine(): cursor.close() async with engine.begin() as conn: + from cartsnitch_api.models.user import User + + User.__table__.columns["email_inbound_token"].server_default = None await conn.run_sync(Base.metadata.create_all) # Create Better-Auth tables (not managed by SQLAlchemy models) await conn.execute(