Skip to content

Add experimental DuckDB dialect to drift#3787

Merged
simolus3 merged 2 commits into
simolus3:developfrom
Hu-Wentao:feat_supprot_duckdb
Apr 28, 2026
Merged

Add experimental DuckDB dialect to drift#3787
simolus3 merged 2 commits into
simolus3:developfrom
Hu-Wentao:feat_supprot_duckdb

Conversation

@Hu-Wentao
Copy link
Copy Markdown
Contributor

Problem

Currently, drift_duckdb still masquerades as SqlDialect.sqlite, causing the Drift DSL to reuse the type semantics of SQLite under DuckDB. The most straightforward issue is that both DriftSqlType.int and DriftSqlType.bigInt use INTEGER, while for DuckDB, 64 - bit integers should be BIGINT. This can lead to errors or sub - optimal results in the schema and cast SQL.

Scope of this PR

  • Introduce SqlDialect.duckdb in drift core.
  • Map built-in types to DuckDB base names: BOOLEAN, TEXT, BIGINT, DOUBLE, BLOB.
  • Keep DuckDB parameter placeholders on ?, and prevent sqlite-style indexed placeholders such as ?1.
  • Reuse generic CAST and ON CONFLICT SQL generation where verified to work for DuckDB.
  • Restrict DuckDB insert modes to an explicit minimal supported set instead of silently reusing sqlite behavior.
  • Add focused SQL generation tests for DuckDB schema types, variables, casts, and a minimal insert/select/returning flow.

What is intentionally not covered yet

  • Full executor-layer support in drift_duckdb.
  • Auto-increment / identity / sequence semantics.
  • DuckDB-specific advanced types such as UUID, STRUCT, LIST, HUGEINT, etc.
  • Deeper migration behavior differences.
  • Full validation of all Drift upsert and conflict edge cases on DuckDB.

Test coverage

  • Schema generation emits BIGINT for int and bigInt.
  • Schema generation emits BOOLEAN for bool.
  • Schema generation emits DOUBLE for double.
  • DuckDB variables use ? and do not emit sqlite-style indexed placeholders.
  • cast<int>() and cast<BigInt>() generate CAST(... AS BIGINT).
  • Minimal insert, select, and RETURNING * SQL generation paths are covered.

ref

Copy link
Copy Markdown
Owner

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Comment thread drift/lib/src/runtime/query_builder/statements/insert.dart Outdated
Copy link
Copy Markdown
Owner

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@simolus3 simolus3 merged commit 4185335 into simolus3:develop Apr 28, 2026
11 checks passed
@Hu-Wentao
Copy link
Copy Markdown
Contributor Author

Hu-Wentao commented Apr 29, 2026

Let me add one more thing. I recommend using the skill I developed to help you achieve automatic release. @simolus3

https://github.com/Hu-Wentao/wyatt_skills/tree/main/skills/publish-flutter-package

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