Since there is no BOOLEAN dataype in SQLite, and BOOLEAN is assigned NUMERIC 
affinity, the sqlite3_column_type() function must be returning SQLITE_INTEGER 
(because storing 0 and 1 as integers is preferred over floats).

So how does the getColumnType() function determine a datatype of BOOLEAN? My 
guess is that it is parsing the column name returned by SQLite - which is in 
itself relying on undetermined behaviour - and assigning an alias will cause 
that to fail. Maybe the above function will "correctly" detect 
my_check_name_BOOLEAN?

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Pavan Paolo
Gesendet: Donnerstag, 15. März 2018 17:43
An: sqlite-users@mailinglists.sqlite.org
Betreff: [EXTERNAL] [sqlite] Boolean casting

Dear all,
I use in a view the following snip of code to force the results to be 
considered as Boolean:
SELECT cast(start_processing_date is not null as BOOLEAN), ...

I need this solution since in this way I can detect in java the Boolean data 
type by querying the ResultSet metadata rs.getMetaData().getColumnType() and 
trigger a proper visualization in a table.

Anyway, this cause to get column name a bit messy, reporting the 
"CAST(non_compliant ..." itself as title of the column.
If I try to use an alias such as the following, I fix the title but I loose the 
Boolean data type.
select cast(start_processing_date is not null as BOOLEAN) as my_check_name, ...

Is this behavior expected? How I can work on it?

Thank you,
Paolo
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | 
Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 
1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to