Visitar URL original
SQLCipherStatement.getColumnType: report SQLITE_DATA_* values (NULL was 0) by ZoeyJones · Pull Request #94 · sqlcipher/sqlcipher-android · GitHub
Skip to content

SQLCipherStatement.getColumnType: report SQLITE_DATA_* values (NULL was 0) - #94

Merged
developernotes merged 2 commits into
sqlcipher:masterfrom
ZoeyJones:fix-getcolumntype-sqlite-data-constants
Sep 29, 2026
Merged

developernotes merged 2 commits into
sqlcipher:masterfrom
ZoeyJones:fix-getcolumntype-sqlite-data-constants

Conversation

@ZoeyJones

Copy link
Copy Markdown
Contributor

SQLCipherStatement implements androidx.sqlite.SQLiteStatement, so getColumnType(int) should return androidx.sqlite's SQLITE_DATA_* constants. It currently returns android.database.Cursor.getType(index) unchanged. The two sets agree for INTEGER, FLOAT, TEXT and BLOB (1–4), but a NULL column reports Cursor.FIELD_TYPE_NULL (0) instead of SQLITE_DATA_NULL (5). With Room 3's room3-sqlite-wrapper, this makes getSupportWrapper().query(...) throw IllegalStateException: Unknown column type: 0 on the first NULL value.

Change

  • getColumnType now maps each Cursor.FIELD_TYPE_* to its SQLite.SQLITE_DATA_* value explicitly, and throws on an unknown value instead of passing it through.
  • Two instrumented tests:
    • SQLCipherConnectionTests: getColumnType reports SQLITE_DATA_* for NULL, INTEGER, FLOAT, TEXT and BLOB.
    • SupportAPIRoomTest: a getSupportWrapper().query(...) over a NULL column succeeds.

Verification

  • On unmodified master (bc71616) the tests fail: expected:<5> but was:<0>, and Unknown column type: 0.
  • With the fix, the whole net.zetetic.database.sqlcipher.driver package passes: 37/37 on an API 36 arm64 emulator.

Contributor agreement

Individual Contributor Agreement signed via DocuSign and completed by Zetetic on 2026-09-27, as requested in #93.

Fixes #93

… values

SQLCipherStatement implements androidx.sqlite.SQLiteStatement, whose
getColumnType contract is androidx.sqlite's SQLITE_DATA_* constants. A
NULL column is currently reported as Cursor.FIELD_TYPE_NULL (0) rather
than SQLITE_DATA_NULL (5), so room3-sqlite-wrapper's toCursor() throws
IllegalStateException: Unknown column type: 0 on any NULL value.
…mnType

getColumnType returned Cursor.getType() unchanged. Cursor.FIELD_TYPE_NULL
is 0 while androidx.sqlite's SQLITE_DATA_NULL is 5, so every NULL column
violated the SQLiteStatement contract. Each Cursor field type is now mapped
explicitly, and an unknown value throws instead of passing through.
@developernotes

Copy link
Copy Markdown
Member

Hi @ZoeyJones,

Thanks for submitting this, we are including this in the 4.19.1 release.

@ZoeyJones

Copy link
Copy Markdown
Contributor Author

Thank you for the trust and support.

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.

SQLCipherStatement.getColumnType returns Cursor.FIELD_TYPE_NULL (0) instead of SQLITE_DATA_NULL (5), breaking room3-sqlite-wrapper on NULL columns

2 participants