You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the code below, updating a column created with boolean type (tinyint in sqlite), results in the string value of the boolean being in the database, instead of 0/1. Insert works as expected. I am not familiar with the structure of this library to check the source of this behaviour myself. It's possible that it's a wider bug and this is just one of the consequences.
sqlite> SELECT * FROM mytable;
1|false
2|1
3|1
4|1
5|false
import allographer/[connection, schema_builder, query_builder]
import asyncdispatch, json
from db_common import DbError
proc createTable(myDb: Rdb) {.async.} =
myDb.create([
table("mytable", [
Column.increments("id"),
Column.boolean("mybool").nullable()
])
])
proc main() {.async.} =
let myDb = dbOpen(Sqlite3, "my.db", maxConnections=10, timeout=30)
await createTable(myDb)
var insertData: seq[JsonNode]
for i in 1..5:
insertData.add(
%*{
"id": i,
"mybool": true
})
myDb.table("mytable").insert(insertData).await
myDb.table("mytable").where("id", "=", 1).update(%*{"mybool": false}).await
myDb.table("mytable").where("id", "=", 5).update(%*{"mybool": false}).await
waitFor main()
The text was updated successfully, but these errors were encountered:
sgmihai
changed the title
Updating a boolean column results in "true"/"false" strings being inserted, instead of integers
Updating a boolean column in sqlite results in "true"/"false" strings being inserted, instead of integers
Jun 8, 2023
Using the code below, updating a column created with boolean type (tinyint in sqlite), results in the string value of the boolean being in the database, instead of 0/1. Insert works as expected. I am not familiar with the structure of this library to check the source of this behaviour myself. It's possible that it's a wider bug and this is just one of the consequences.
https://play.nim-lang.org/#ix=4xLn
The text was updated successfully, but these errors were encountered: