Artem Avramenko <art...@devart.com> wrote: > Another example: > > CREATE TABLE a ( > id int, > flags int > ); > INSERT INTO a VALUES(1, 0); > INSERT INTO a VALUES(2, 1); > > CREATE TABLE b AS > SELECT id, (flags & 1) as flag FROM a where (flags & 1) = 1; > > > In following SQL sqlite3_column_type returns null affinity: > > SELECT b.flag FROM a > LEFT JOIN b ON a.id = b.id;
sqlite3_column_type returns the actual type of a particular field, not the affinity of the overall column. sqlite3_column_type always reports NULL if you are not currently positioned on any row (haven't called sqlite3_step yet), or if the field you are querying is in fact NULL. > Why? All columns are declared as integer. sqlite3_column_type doesn't care how a column is declared. > If JOIN is used or table at right side contains joined row (e.g., > (1,0) and (1,1)), sqlite3_column_type returns INT64 Because this way there are no NULL fields in the resultset. Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users