clsql
clsql copied to clipboard
clsql bug: number and locale
Hello,
I have a problem with clsql when I read float numbers from a database (I use sqlite3). The following repl commands show the problem:
CLSQL-USER> (connect ":memory:" :database-type :sqlite3) #<CLSQL-SQLITE3:SQLITE3-DATABASE :memory: OPEN {1005C67B73}> CLSQL-USER> (enable-sql-reader-syntax) ; No value CLSQL-USER> (create-table [tbl1] '(([numint] integer) ([numflt] float))) ; No value CLSQL-USER> (insert-records :into [tbl1] :attributes '([numint] [numflt]) :values '(1 1.2)) ; No value CLSQL-USER> (select [*] :from [tbl1]) ((1 1.0d0)) ("NUMINT" "NUMFLT") CLSQL-USER> (select [*] :from [tbl1] :result-types nil) (("1" "1.2")) ("NUMINT" "NUMFLT")
The numbers are stored right in database as shows the last command but are read wrong. This is due to my locale "it_IT-UTF-8". If I change locale to "en_US-UTF-8" all is right.
The problem is in function convert-raw-field
in file clsql-uffi.lisp
where is used the c-function atof
to convert from string to double, but
this c function depends on locale (point or comma as decimal separator).
PS: I tried to send this bug in the mailing list as written on README but the mailing list is down.