PcolumnTypes
Bun

property

sqlite.Statement.columnTypes

readonly columnTypes: null | 'INTEGER' | 'FLOAT' | 'TEXT' | 'BLOB' | 'NULL'[]

The actual SQLite column types from the first row of the result set. Useful for expressions and computed columns, which are not covered by declaredTypes

Returns an array of SQLite type constants as uppercase strings:

  • "INTEGER" for integer values
  • "FLOAT" for floating-point values
  • "TEXT" for text values
  • "BLOB" for binary data
  • "NULL" for null values
  • null for unknown/unsupported types

Requirements:

  • Only available for read-only statements (SELECT queries)
  • For non-read-only statements, throws an error

Behavior:

  • Uses sqlite3_column_type() to get actual data types from the first row
  • Returns null for columns with unknown SQLite type constants
const stmt = db.prepare("SELECT id, name, age FROM users WHERE id = 1");

console.log(stmt.columnTypes);
// => ["INTEGER", "TEXT", "INTEGER"]

// For expressions:
const exprStmt = db.prepare("SELECT length('bun') AS str_length");
console.log(exprStmt.columnTypes);
// => ["INTEGER"]