philippmdoerner / lowdb Goto Github PK
View Code? Open in Web Editor NEWA fork of nim's db_sqlite library based on ndb with proper typing
License: MIT License
A fork of nim's db_sqlite library based on ndb with proper typing
License: MIT License
In sqlite, generally when you fire off a query and you have more parameters than corresponding placeholders in the query, you will receive a DBError.
See tests in the suite tsqlite.nim - suite "Prepared statement finalization":
for examples.
insertId, rows etc. in postgres does not emit that behaviour. Fix that
Minimal example:
import lowdb/sqlite
import std/unittest
let dbConn = open(":memory:", "", "", "")
dbConn.exec sql"CREATE TABLE t1 (id SERIAL PRIMARY KEY, value TEXT)"
let id = dbConn.insertID sql"INSERT INTO t1(value) VALUES ('a')"
let rows: seq[Row] = dbConn.getAllRows(sql "SELECT * FROM t1")
assert rows.len == 1
let expectedValue: seq[Row] = @[
@[
DbValue(kind: dvkInt, i: id),
DbValue(kind: dvkString, s: "a")
]
]
check rows == expectedValue
expectation: This should succeed.
insertID
should insert an entry into the table AND add an auto-generated ID.
Currently it does not do that, it only adds the entry, it doesn't set the generated id.
SideInformation:
What's mysterious about this is, that it appears to generally work for norm, which is using lowdb and makes extensive use of it.
It also occurs in both nim 1.6.10 and 1.9.1, so it's not a bug caused by devel.
tryInsertID
is implemented, but not for postgres, leading to various tests for postgres in tPostgres.nim
being commented out.
The specification for that proc can be seen in tsqlite.nim - suite "Prepared statement finalization":
.
getValue
is implemented, but not for postgres, leading to various tests for postgres in tPostgres.nim being commented out.
The specification for that proc can be seen in tsqlite.nim - suite "getValue()":
Line 79 in 1b81b57
{.deadCodeElim: on.}
is a deprecated noop and should be removed. Likewise, search {.deadCodeElim: on.}
and replace them with empty strings.
DbBlob
is implemented, but not for postgres, leading to various tests for postgres in tPostgres.nim
being commented out.
The specification for that type is the same as sqlite, check out sqlite.nim
and tsqlite.nim
for basics of the specification.
instantRows
is implemented, but not for postgres, leading to various tests for postgres in tPostgres.nim being commented out.
The specification for that iterator can be seen in tsqlite.nim - suite "suite "instantrows-iterator":
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.