summary refs log tree commit diff stats
path: root/lib/impure
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-09-15 21:12:59 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-09-15 21:12:59 +0200
commitecf1424456bd95167ac0e1e721307032e22d172f (patch)
tree61781a1a7f4a037cfe88afc0988555e0b17d9782 /lib/impure
parent0fe2a83dda25d682f04f7af0f73a50c45362c79f (diff)
parent8ea78b1bc9dc0b4d883b4f0750ee84e93605b82a (diff)
downloadNim-ecf1424456bd95167ac0e1e721307032e22d172f.tar.gz
Merge branch 'devel' into araq
Diffstat (limited to 'lib/impure')
-rw-r--r--lib/impure/db_postgres.nim11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim
index fc587b5df..a42950557 100644
--- a/lib/impure/db_postgres.nim
+++ b/lib/impure/db_postgres.nim
@@ -516,10 +516,13 @@ proc open*(connection, user, password, database: string): DbConn {.
   ##
   ## See http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING
   ## for more information.
-  ##
-  ## Note that the connection parameter is not used but exists to maintain
-  ## the nim db api.
-  result = pqsetdbLogin(nil, nil, nil, nil, database, user, password)
+  let
+    colonPos = connection.find(':')
+    host = if colonPos < 0: connection
+           else: substr(connection, 0, colonPos-1)
+    port = if colonPos < 0: ""
+           else: substr(connection, colonPos+1)
+  result = pqsetdbLogin(host, port, nil, nil, database, user, password)
   if pqStatus(result) != CONNECTION_OK: dbError(result) # result = nil
 
 proc setEncoding*(connection: DbConn, encoding: string): bool {.