fix: Use db.insert() for ticket creation to fix SQLite serialization #1

Closed
padreug wants to merge 0 commits from fix/sqlite-ticket-extra-serialization into main
Owner

Summary

  • Fix SQLite error when purchasing event tickets: type 'dict' is not supported
  • Replace db.execute() with db.insert() for proper Pydantic model serialization
  • Works across all database backends (SQLite, PostgreSQL, CockroachDB)

Problem

The create_ticket() function used db.execute() with a raw dict from ticket.dict(). The extra field (a TicketExtra Pydantic model) was converted to a Python dict that SQLite cannot serialize directly.

Solution

Use db.insert() which properly handles Pydantic model serialization, converting the extra field to JSON automatically. This is consistent with how create_event() already works.

TODO Added

Added a TODO comment to review the empty string workaround for name/email fields - this pattern converts None to empty strings for database storage and back to None when reading.

Merged manually via git CLI

🤖 Generated with Claude Code

## Summary - Fix SQLite error when purchasing event tickets: `type 'dict' is not supported` - Replace `db.execute()` with `db.insert()` for proper Pydantic model serialization - Works across all database backends (SQLite, PostgreSQL, CockroachDB) ## Problem The `create_ticket()` function used `db.execute()` with a raw dict from `ticket.dict()`. The `extra` field (a `TicketExtra` Pydantic model) was converted to a Python dict that SQLite cannot serialize directly. ## Solution Use `db.insert()` which properly handles Pydantic model serialization, converting the `extra` field to JSON automatically. This is consistent with how `create_event()` already works. ## TODO Added Added a TODO comment to review the empty string workaround for name/email fields - this pattern converts None to empty strings for database storage and back to None when reading. **Merged manually via git CLI** 🤖 Generated with [Claude Code](https://claude.com/claude-code)
padreug added 1 commit 2026-01-03 16:49:10 +00:00
fix: Use db.insert() for ticket creation to fix SQLite serialization
Some checks failed
lint / lint (push) Waiting to run
lint / lint (pull_request) Has been cancelled
a77145e08e
The previous implementation used db.execute() with a raw dict, which
failed on SQLite because the 'extra' field (TicketExtra model) was
passed as a Python dict that SQLite cannot serialize.

Using db.insert() with the Pydantic model ensures proper JSON
serialization of the extra field across all database backends
(SQLite, PostgreSQL, CockroachDB).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
padreug closed this pull request 2026-01-03 16:52:10 +00:00
Some checks failed
lint / lint (push) Waiting to run
lint / lint (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: aiolabs/events#1
No description provided.