summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnatoly Galiulin <galiulin.anatoly@gmail.com>2015-11-06 10:24:23 +0600
committerAnatoly Galiulin <galiulin.anatoly@gmail.com>2015-11-06 10:24:23 +0600
commitc0179043639ceab4f146fda2eec906fc30740b4b (patch)
tree46546da3e73516c84ab43d9ba0db50e5707ee91a
parentae60f4ae760223c57403f2ac59014374b4655377 (diff)
downloadNim-c0179043639ceab4f146fda2eec906fc30740b4b.tar.gz
Fixed issue 3513: wrong setupQuery realization
-rw-r--r--lib/impure/db_postgres.nim8
-rw-r--r--tests/untestable/tpostgres.nim4
2 files changed, 5 insertions, 7 deletions
diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim
index 7e6219465..5603d9686 100644
--- a/lib/impure/db_postgres.nim
+++ b/lib/impure/db_postgres.nim
@@ -167,11 +167,7 @@ proc newRow(L: int): Row =
 
 proc setupQuery(db: DbConn, query: SqlQuery,
                 args: varargs[string]): PPGresult =
-  # s is a dummy unique id str for each setupQuery query
-  let s = "setupQuery_Query_" & string(query)
-  var res = pqprepare(db, s, dbFormat(query, args), 0, nil)
-  result = pqexecPrepared(db, s, 0, nil,
-                        nil, nil, 0)
+  result = pqexec(db, dbFormat(query, args))
   if pqResultStatus(result) != PGRES_TUPLES_OK: dbError(db)
 
 proc setupQuery(db: DbConn, stmtName: SqlPrepared,
@@ -380,4 +376,4 @@ proc setEncoding*(connection: DbConn, encoding: string): bool {.
   return pqsetClientEncoding(connection, encoding) == 0
 
 
-# Tests are in ../../tests/untestable/tpostgres.
\ No newline at end of file
+# Tests are in ../../tests/untestable/tpostgres.
diff --git a/tests/untestable/tpostgres.nim b/tests/untestable/tpostgres.nim
index 5f29da091..81fe8bf51 100644
--- a/tests/untestable/tpostgres.nim
+++ b/tests/untestable/tpostgres.nim
@@ -9,5 +9,7 @@ let name = "Dom"
 db.exec(sql"INSERT INTO myTable (id, name) VALUES (0, ?)",
         name)
 doAssert db.getValue(sql"SELECT name FROM myTable") == name
+# Check issue #3513
+doAssert db.getValue(sql"SELECT name FROM myTable") == name
 
-db.close()
\ No newline at end of file
+db.close()