Skip to content

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
niinivaa committed Aug 11, 2021
1 parent 3ddb308 commit b65f656
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ type SqlStatements = enum
SelectAll = "SELECT count FROM Example"
var db: SQLiteral
proc operate() =
echo "count=",db.getTheInt(Select, 1)
db.transaction: db.exec(Increment, 1)
for row in db.rows(SelectAll): echo row.getInt(CountColumn)
when not defined(release):
db.setLogger(proc(db: SQLiteral, msg: string, code: int) = echo msg)
db.openDatabase("example.db", Schema)
db.prepareStatements(SqlStatements)
echo "count=",db.getTheInt(Select, 1)
db.transaction: db.exec(Increment, 1)
for row in db.rows(SelectAll): echo row.getInt(CountColumn)
db.close
operate()
db.close()
```
2 changes: 1 addition & 1 deletion sqliteral.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "2.0.0"
version = "2.0.1"
author = "Olli"
description = "A high level SQLite API for Nim"
license = "MIT"
Expand Down
13 changes: 8 additions & 5 deletions src/sqliteral.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const SQLiteralVersion* = "2.0.0"
const SQLiteralVersion* = "2.0.1"

# (C) Olli Niinivaara, 2020-2021
# MIT Licensed
Expand Down Expand Up @@ -74,7 +74,8 @@ const SQLiteralVersion* = "2.0.0"
## consult sqliteral source code or `about()` proc for details.
## These can be turned off with `-d:disableSqliteoptions` option.
##
##
##


when compiles((var x = 1; var vx: var int = x)):
const ViewsAvailable = true
Expand Down Expand Up @@ -230,7 +231,6 @@ var emptystart = cast[ptr UncheckedArray[char]](addr emptytext[0])
when compileOption("threads"):
proc threadi*(db: SQLiteral): int = # public only for technical reasons
let id = getThreadId()
echo db.threadindices
for i in 0 ..< db.threadlen: (if db.threadindices[i] == id: return i)
doAssert(false, "uninitialized thread - has prepareStatements been called on this thread?")
else:
Expand Down Expand Up @@ -328,13 +328,16 @@ template log() =
var replacement = 0
while replacement < params.len:
let position = logstring.find('?')
assert(position != -1, "too many params (" & $params.len & ") for: " & $statement)
if (position == -1):
logstring = $params.len & "is too many params for: " & $statement
replacement = params.len
continue
let param =
if db.maxparamloggedlen < 1: $params[replacement]
else: ($params[replacement]).substr(0, db.maxparamloggedlen - 1)
logstring = logstring[0 .. position-1] & param & logstring.substr(position+1)
replacement += 1
assert(logstring.find('?') == -1, $params.len & " is not enough params for: " & $statement)
if (logstring.find('?') != -1): logstring = $params.len & " is not enough params for: " & $statement
db.loggerproc(db, logstring, 0)


Expand Down

0 comments on commit b65f656

Please sign in to comment.