Row dependent column type
Is the following behavior as intended?
ResultSet rs = statement.executeQuery("SELECT NULL UNION SELECT 1"); # One column with 2 rows (NULL, 1)
rs.next();
rs.getMetaData().getColumnTypeName(1); # NULL
rs.next();
rs.getMetaData().getColumnTypeName(1); # INTEGER
This issue is the same as #112. I can't answer if that was the intention, but that is the implementation.
The problem lies in SQLite. The column type-name from ResultSetMetaData#getColumnTypeName is retrieved from sqlite3_column_decltype. The documentation of sqlite3_column_decltype states:
SQLite uses dynamic run-time typing. So just because a column is declared to contain a particular type does not mean that the data stored in that column is of the declared type. SQLite is strongly typed, but the typing is dynamic not static. Type is associated with individual values, not with the containers used to hold those values. [Source]
So I guess, either SQLite determines the value NULL to be of a NULL-type or it cannot determine the type of the value. In either case SQLite-JDBC returns "NULL" in JDBC3ResultSet#getColumnTypeName.