tursodatabase / turso-cli

Command line interface to Turso.
https://turso.tech
MIT License
224 stars 37 forks source link

sqld no longer accepts integer values in bound parameter args #93

Closed CodingDoug closed 1 year ago

CodingDoug commented 1 year ago

If I send:

{"statements":["BEGIN",{"q":"update users set coins = ? where id = ?","params":[1,"001"]},"COMMIT"]}

I get this error from sqld:

Error: invalid type: integer 1, expected a valid SQLite value at line 1 column 81

changing it to a string “1” works fine. But I really don’t think I should have to.

haaawk commented 1 year ago

I tried this and it seems to work:

╰──> ./turso db create t                                                                                              
Created database t to Warsaw, Poland (waw) in 11 seconds.

You can start an interactive SQL shell with:

   turso db shell t

To obtain connection URL, run:

   turso db show --url t

╰──> ./turso db shell t
Connected to t at https://haaawk:P5s948Yn72tr3106@t-haaawk.turso.io

Welcome to Turso SQL shell!

Type ".quit" to exit the shell, ".tables" to list all tables, and ".schema" to show table schemas.

→  CREATE TABLE IF NOT EXISTS counter(country TEXT, city TEXT, value INT, PRIMARY KEY(country, city)) WITHOUT ROWID;

→  .quit

╰──> ./turso db show t
Name:     t
URL:      https://haaawk:P5s948Yn72tr3106@t-haaawk.turso.io
ID:       92b096b0-b0df-11ed-bf5d-82dd9b475001
Regions:  waw

Database Instances:
NAME             TYPE        REGION     URL                                                              
endless-doll     primary     waw        https://haaawk:P5s948Yn72tr3106@9185133f456783-t-haaawk.turso.io     

╰──> curl -X POST -d '{"statements":[{"q":"insert into counter(country, city, value) values(?, ?, ?)","params":["US", "SFO", 5]}]}' https://haaawk:P5s948Yn72tr3106@9185133f456783-t-haaawk.turso.io
[{"results":{"columns":[],"rows":[]}}]%                                                                                                                                                                                     

╰──> ./turso db shell t "select * from counter"
COUNTRY  CITY  VALUE  
US       SFO   5 

Closing... @CodingDoug please reopen if you still observe the problem.