diff options
author | flywind <xzsflywind@gmail.com> | 2021-08-13 00:21:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 09:21:01 -0700 |
commit | f559319a682fb2abbf2945fd3390585a54f044d5 (patch) | |
tree | c891e6bda03e8ab20e972ec2700b3d3868d7b947 /tests/stdlib/tsqlitebindatas.nim | |
parent | 5c1304a4181596e764b05679cd8a0044ab3398dd (diff) | |
download | Nim-f559319a682fb2abbf2945fd3390585a54f044d5.tar.gz |
fix a sqlite bug (#18669)
Diffstat (limited to 'tests/stdlib/tsqlitebindatas.nim')
-rw-r--r-- | tests/stdlib/tsqlitebindatas.nim | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/stdlib/tsqlitebindatas.nim b/tests/stdlib/tsqlitebindatas.nim index 643f1e2e6..754c80ae1 100644 --- a/tests/stdlib/tsqlitebindatas.nim +++ b/tests/stdlib/tsqlitebindatas.nim @@ -48,3 +48,31 @@ block tsqlitebindatas: ## db_sqlite binary data db.close() doAssert tryRemoveFile(dbName) + + +block: + block: + const dbName = buildDir / "db.sqlite3" + var db = db_sqlite.open(dbName, "", "", "") + var witness = false + try: + db.exec(sql("CREATE TABLE table1 (url TEXT, other_field INT);")) + db.exec(sql("REPLACE INTO table (url, another_field) VALUES (?, '123');")) + except DbError as e: + witness = true + doAssert e.msg == "The number of \"?\" given exceeds the number of parameters present in the query." + finally: + db.close() + removeFile(dbName) + + doAssert witness + + block: + const dbName = buildDir / "db.sqlite3" + var db = db_sqlite.open(dbName, "", "", "") + try: + db.exec(sql("CREATE TABLE table1 (url TEXT, other_field INT);")) + db.exec(sql("INSERT INTO table1 (url, other_field) VALUES (?, ?);"), "http://domain.com/test?param=1", 123) + finally: + db.close() + removeFile(dbName) |