diff options
author | jfilby <jason.filby@gmail.com> | 2022-11-27 20:28:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-27 19:28:38 +0100 |
commit | 5a848a070759c4b5fa868741b430f96586a9ac18 (patch) | |
tree | e41f357fc3c48ca0a8ecbd2963ce99f16756c217 /tests/untestable | |
parent | f644f046540a1a3a59aecf5468bc4d9ae0ea101f (diff) | |
download | Nim-5a848a070759c4b5fa868741b430f96586a9ac18.tar.gz |
Fix several memory leaks in the Postgres wrapper. (#20940)
Diffstat (limited to 'tests/untestable')
-rw-r--r-- | tests/untestable/tpostgres.nim | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/untestable/tpostgres.nim b/tests/untestable/tpostgres.nim index d3397e53a..e9f2403e2 100644 --- a/tests/untestable/tpostgres.nim +++ b/tests/untestable/tpostgres.nim @@ -2,6 +2,7 @@ import db_postgres, strutils let db = open("localhost", "dom", "", "test") + db.exec(sql"DROP TABLE IF EXISTS myTable") db.exec(sql("""CREATE TABLE myTable ( id integer PRIMARY KEY, @@ -49,9 +50,12 @@ try: doAssert false, "Exception expected" except DbError: let msg = getCurrentExceptionMsg().normalize - doAssert "expects" in msg - doAssert "?" in msg - doAssert "parameter substitution" in msg + + info "DbError", + msg = $msg + + doAssert "no parameter" in msg + doAssert "$1" in msg doAssert db.getValue(sql("select filename from files where id = ?"), 1) == "hello.tmp" @@ -315,11 +319,11 @@ db.exec(sql("""CREATE TABLE DICTIONARY( var entry = "あっそ" var definition = "(int) (See ああそうそう) oh, really (uninterested)/oh yeah?/hmmmmm" discard db.getRow( - SqlQuery("INSERT INTO DICTIONARY(entry, definition) VALUES(\'$1\', \'$2\') RETURNING id" % [entry, definition])) + sql("INSERT INTO DICTIONARY(entry, definition) VALUES(?, ?) RETURNING id"), entry, definition) doAssert db.getValue(sql"SELECT definition FROM DICTIONARY WHERE entry = ?", entry) == definition entry = "Format string entry" definition = "Format string definition" -db.exec(sql"INSERT INTO DICTIONARY(entry, definition) VALUES (?, ?)", entry, definition) +db.exec(SqlQuery("INSERT INTO DICTIONARY(entry, definition) VALUES (?, ?)"), entry, definition) doAssert db.getValue(sql"SELECT definition FROM DICTIONARY WHERE entry = ?", entry) == definition echo("All tests succeeded!") |