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

1 auto db = Database(":memory:");
2 db.run("CREATE TABLE items (name TEXT, price REAL);
3         INSERT INTO items VALUES ('car', 20000);
4         INSERT INTO items VALUES ('air', 'free');");
5 
6 auto results = db.execute("SELECT name, price FROM items");
7 
8 auto row = results.front;
9 assert(row.columnType(0) == SqliteType.TEXT);
10 assert(row.columnType("price") == SqliteType.FLOAT);
11 assert(row.columnDeclaredTypeName(0) == "TEXT");
12 assert(row.columnDeclaredTypeName("price") == "REAL");
13 
14 results.popFront();
15 row = results.front;
16 assert(row.columnType(0) == SqliteType.TEXT);
17 assert(row.columnType("price") == SqliteType.TEXT);
18 assert(row.columnDeclaredTypeName(0) == "TEXT");
19 assert(row.columnDeclaredTypeName("price") == "REAL");

See Also

Meta