PdeclaredTypes
Bun

property

sqlite.Statement.declaredTypes

readonly declaredTypes: null | string[]

The declared column types from the table schema.

Returns an array of declared type strings from sqlite3_column_decltype():

  • Raw type strings as declared in the CREATE TABLE statement
  • null for columns without declared types (e.g., expressions, computed columns)

Requirements:

  • Statement must be executed at least once before accessing this property
  • Available for both read-only and read-write statements

Behavior:

  • Uses sqlite3_column_decltype() to get schema-declared types
  • Returns the exact type string from the table definition
// For table columns:
const stmt = db.prepare("SELECT id, name, weight FROM products");
stmt.get();
console.log(stmt.declaredTypes);
// => ["INTEGER", "TEXT", "REAL"]

// For expressions (no declared types):
const exprStmt = db.prepare("SELECT length('bun') AS str_length");
exprStmt.get();
console.log(exprStmt.declaredTypes);
// => [null]