Skip to content

Conversation

@CollierKing
Copy link
Owner

@CollierKing CollierKing commented Dec 15, 2025

Summary

  • Refactored compilers to inherit from SQLite base classes (SQLiteCompiler, SQLiteDDLCompiler, SQLiteTypeCompiler) instead of generic SQLAlchemy compilers
  • Adds support for INSERT ... ON CONFLICT DO UPDATE (upsert operations)
  • Fixes duplicate PRIMARY KEY constraint in CREATE TABLE statements
  • Fixes AUTOINCREMENT being incorrectly added to non-INTEGER PRIMARY KEY columns

Changes

  • CloudflareD1Compiler now inherits from SQLiteCompiler
  • CloudflareD1DDLCompiler now inherits from SQLiteDDLCompiler with custom get_column_specification and create_table_constraints to handle D1-specific behavior
  • CloudflareD1TypeCompiler now inherits from SQLiteTypeCompiler
  • Added 4 new unit tests for upsert compilation, DDL generation, and inheritance verification

Test plan

  • All 10 unit tests pass
  • Linting passes (ruff check/format)
  • Manual testing with langchain-cloudflare integration

- Changed CloudflareD1Compiler to inherit from SQLiteCompiler
- Changed CloudflareD1DDLCompiler to inherit from SQLiteDDLCompiler
- Changed CloudflareD1TypeCompiler to inherit from SQLiteTypeCompiler

This enables proper SQLite SQL generation including:
- INSERT ... ON CONFLICT DO UPDATE (upsert) support
- Correct PRIMARY KEY handling (no duplicate constraints)
- No AUTOINCREMENT on non-INTEGER columns

Added tests for upsert compilation, DDL generation, and inheritance.
@CollierKing CollierKing merged commit 723fe92 into main Dec 15, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants