diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index dd805767..e564cfc7 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -374,8 +374,6 @@ conn_sync_connect(connectionObject *self) Dprintf("conn_connect: using protocol %d", self->protocol); - self->server_version = (int)PQserverVersion(pgconn); - /* if the connection is green, wait to finish connection */ if (green) { wait_rv = psyco_wait(self); @@ -386,6 +384,8 @@ conn_sync_connect(connectionObject *self) } } + self->server_version = (int)PQserverVersion(pgconn); + /* From here the connection is considered ready: with the new status, * poll() will use PQisBusy instead of PQconnectPoll. */ diff --git a/tests/test_connection.py b/tests/test_connection.py index 277616b4..dbb80afa 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -45,8 +45,12 @@ class ConnectionTests(unittest.TestCase): self.assert_(conn.notices) conn.close() + def test_server_version(self): + conn = self.connect() + self.assert_(conn.server_version) + def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__) if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main()