mirror of
https://github.com/allankoechke/turso.git
synced 2026-11-30 11:12:58 +00:00
Introduce the Dialect trait as the boundary between the engine and the SQL dialect a frontend speaks. The engine hardcodes SQLite behavior in many places; the trait is the seam where a frontend substitutes its own surface, growing one hook per behavior that moves behind it, with SqliteDialect in core/dialect/sqlite.rs as the SQLite implementation. The first hook is schema loading: every path that parses a sqlite_schema table row back into a table definition now goes through Dialect::parse_table_sql instead of calling BTreeTable::from_sql directly. Rows written by internal engine paths (sequence backing tables, sqlite_sequence) are plain SQLite text with no frontend marker, so every dialect falls back to SQLite parsing for text it does not recognize as its own. The dialect is a mandatory, explicit argument on every database constructor — open_file, open, open_new, from_uri, and the async and bypass-registry variants — with no defaulting convenience wrappers: SQLite-compatible callers state Arc::new(SqliteDialect) at the call site, so the dialect a database runs under is always visible where it is opened. It is fixed at open time because the schema is parsed during open itself; a dialect installed later could never see rows stored by another frontend. The process-wide database registry rejects an open whose dialect name differs from the already-open instance, and engine-initiated secondary opens (ATTACH) propagate the parent database's dialect instead of assuming SQLite.
Turso JDBC Driver
The Turso JDBC driver is a library for accessing and creating Turso database files using Java.
Project Status
The project is actively developed. Feel free to open issues and contribute.
To view related works, visit this issue.
How to use
Currently, we have not published to the maven central. Instead, you can locally build the jar and deploy it to maven local to use it.
Build jar and publish to maven local
$ cd bindings/java
# Please select the appropriate target platform, currently supports `macos_x86`, `macos_arm64`, `windows` and `linux_x86`
$ make macos_x86
# deploy to maven local
$ make publish_local
Now you can use the dependency as follows:
dependencies {
implementation("tech.turso:turso:0.0.1-SNAPSHOT")
}
Code style
- Favor composition over inheritance. For example,
JDBC4Connectiondoesn't implementTursoConnection. Instead, it includesTursoConnectionas a field. This approach allows us to preserve the characteristics of Turso usingTursoConnectioneasily while maintaining interoperability with the Java world usingJDBC4Connection.