[Pharo-users] SQLite3 [UDBC2] - "Could not coerce arguments" error for UTF8 chars
pierce at samadhiweb.com
Tue Feb 5 21:30:23 EST 2019
On Tue, Feb 05, 2019 at 08:20:22PM +0100, Petr Fischer via Pharo-users wrote:
> But still... I do not expect anyone to create tables through binding
> values (like in your example), so following SQL command is still
> db execute: 'create table A (ID INTEGER, T TEXT DEFAULT ''áěšřčá'')'.
Your original mail was about insert, not create.
Anyhow, I think I see the problem: SQLite's APIs accept UTF8-encoded SQL
input strings. UDBCSQLite just uses UFFI's String to char* conversion to
pass strings in Pharo to the FFI calls. But 'áěšřčá' is a WideString.
Judiciously sending #utf8Encoded to the input SQL string seems to do the
| db |
db := UDBCSQLite3Connection openOn: '/tmp/u.db'.
[ | rs |
db execute: 'create table a (k, v varchar default ''ěščřžýáíéúůĚŠČŘŽÝÁÍÉÚŮ'')'.
db execute: 'insert into a (k) values (NULL)'.
rs := db execute: 'select k, v from a'.
rs next inspect.
] ensure: [ db close ]
Above snippet evaluates to an inspector on a UDBCSQLite3Row instance
with the expected data. See screenshot.
I should be able to fix this in UDBCSQLite over the next two days as it
is Chinese New Year long holiday here.
Btw, you mentioned UDBC2. Not speaking for Torsten but I believe UDBC2
is WIP experimental stuff. Better to use UDBCSQLite. Easiest way to load
is to install GlorpSQLite via the Catalog Browser. Ignore the warning
that the package is not tested for Pharo 7 - that's a Catalog Browser
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 100919 bytes
Desc: not available
More information about the Pharo-users