Skip to content

Report database product name as exactly SQLite so dialect detection works #261

Closed

Description

@magnusp

Goal

Return exactly SQLite from DatabaseMetaData.getDatabaseProductName(), keeping the libSQL identity in getDriverName() (libSQL JDBC Driver) and getDatabaseProductVersion().

Exact-match consumers currently fail to recognise the database as SQLite. Liquibase is the clear case: it selects its SQLite dialect only when "SQLite".equalsIgnoreCase(getDatabaseProductName()).

Current behavior

libsql-jdbc/src/main/java/io/github/magnusp/libsql/jdbc/LibsqlDatabaseMetaData.java:207 returns SQLite (libSQL).

  • Liquibase 5.0.3 SQLiteDatabase.isCorrectDatabaseImplementation uses PRODUCT_NAME.equalsIgnoreCase(...), so DatabaseFactory.findCorrectDatabaseImplementation returns UnsupportedDatabase. The first update then emits CREATE TABLE ... (id INT GENERATED BY DEFAULT AS IDENTITY ...), which sqld rejects with a syntax error. Pinned by LiquibaseIT#databaseFactoryFallsBackToUnsupportedDatabase in test(jdbc): add Liquibase integration smoke tests #257, together with the explicit SQLiteDatabase workaround in LiquibaseIT#liquibase.
  • jOOQ maps the product name to SQLDialect; JDBCUtils.dialect(connection) resolves to SQLDialect.DEFAULT instead of SQLITE.
  • Flyway is unaffected because its SQLite plugin uses startsWith("SQLite").

Why this is safe

  • xerial/sqlite-jdbc returns SQLite. Matching it is the interoperability contract, and getDriverName() already carries the libSQL identity.
  • LibsqlConformanceGuard also checks sqlite_source_id() ends in alt1, so it can rely on the driver name plus that suffix to reject xerial and a non-libSQL server.

Where

Main:

  • libsql-jdbc/src/main/java/io/github/magnusp/libsql/jdbc/LibsqlDatabaseMetaData.java:207

Tests and fixtures that assert the old string:

  • libsql-itests/src/test/java/io/github/magnusp/libsql/itest/WebSocketTransportIT.java:110 (exact equality)
  • libsql-itests/src/test/java/io/github/magnusp/libsql/itest/LibsqlJdbcIT.java:116 (contains("libSQL"))
  • libsql-conformance/src/test/java/io/github/magnusp/libsql/conformance/LibsqlConformanceGuard.java:13 (EXPECTED_DATABASE_PRODUCT_NAME)
  • libsql-conformance/src/test/java/io/github/magnusp/libsql/conformance/LibsqlConformanceGuardTest.java (two SQLite (libSQL) fixtures)

Liquibase tests from #257:

  • Delete LiquibaseIT#databaseFactoryFallsBackToUnsupportedDatabase.
  • Change the LiquibaseIT#liquibase helper to use DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(conn)).
  • Keep LiquibaseIT#databaseFactoryCannotResolveALibsqlUrlToADriver; it is independent of the product name.

The jOOQ dialect pin added on feat/jooq-itests should be updated in the same wave.

Fix

Return exactly SQLite. Update the guard to keep checking the driver name and the sqlite_source_id() suffix, update the four assertions above, then unpin the Liquibase gap as described.

Verification

  • ./mvnw -pl libsql-jdbc -am verify -Dit.test=LiquibaseIT: the Liquibase tests pass through the normal DatabaseFactory path, without the explicit SQLiteDatabase.
  • ./mvnw -pl libsql-conformance -am verify
  • ./mvnw -pl libsql-itests -am verify (with the shared DOCKER_CONFIG described in AGENTS.md)
  • ./mvnw spotless:check

Found while adding the Liquibase integration tests in #257.

Activity

  1. added
    bugSomething isn't working
    P1High priority: significant correctness or compatibility gap
    on Oct 30, 2026
  2. added 2 commits that reference this issue on Oct 31, 2026
    bda077b
    161af09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priority: significant correctness or compatibility gapbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions