Row.columnType

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.

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