Row.columnDeclaredTypeName

Determines the type of the data in a particular column.

columnType returns the type of the actual data in that column, whereas columnDeclaredTypeName returns the name of the type as declared in the SELECT statement.

  1. string columnDeclaredTypeName(size_t index)
    struct Row
    string
    columnDeclaredTypeName
    (
    size_t index
    )
  2. string columnDeclaredTypeName(string columnName)
  3. SqliteType columnType(size_t index)
  4. SqliteType columnType(string columnName)

Examples

auto db = Database(":memory:");
db.run("CREATE TABLE items (name TEXT, price REAL);
        INSERT INTO items VALUES ('car', 20000);
        INSERT INTO items VALUES ('air', 'free');");

auto results = db.execute("SELECT name, price FROM items");

auto row = results.front;
assert(row.columnType(0) == SqliteType.TEXT);
assert(row.columnType("price") == SqliteType.FLOAT);
assert(row.columnDeclaredTypeName(0) == "TEXT");
assert(row.columnDeclaredTypeName("price") == "REAL");

results.popFront();
row = results.front;
assert(row.columnType(0) == SqliteType.TEXT);
assert(row.columnType("price") == SqliteType.TEXT);
assert(row.columnDeclaredTypeName(0) == "TEXT");
assert(row.columnDeclaredTypeName("price") == "REAL");

See Also

Meta