Permalink
Browse files

Inline validate_datetyle check

  • Loading branch information...
1 parent 9d9401a commit df27a4346797d4461a1e2a0353c5478e825fce99 @mvantellingen mvantellingen committed Oct 16, 2011
Showing with 2 additions and 11 deletions.
  1. +2 −1 psycopg2ct/_impl/connection.py
  2. +0 −10 psycopg2ct/_impl/util.py
@@ -530,7 +530,8 @@ def _poll_setup_async(self):
# If the current datestyle is not compatible (not ISO) then
# force it to ISO
- if not util.validate_datestyle(self._pgconn):
+ datestyle = libpq.PQparameterStatus(self._pgconn, 'DateStyle')
+ if not datestyle or not datestyle.startswith('ISO'):
self.status = consts.STATUS_DATESTYLE
if libpq.PQsendQuery(self._pgconn, "SET DATESTYLE TO 'ISO'"):
View
@@ -38,16 +38,6 @@ def quote_string(conn, value):
return obj.getquoted()
-def validate_datestyle(pgconn):
- """Validates if the datestyle is an ISO format"""
- datestyle = libpq.PQparameterStatus(pgconn, 'DateStyle')
-
- # pgbouncer does not pass on DateStyle
- if datestyle is None:
- return False
- return datestyle.startswith('ISO')
-
-
def get_exception_for_sqlstate(code):
"""Translate the sqlstate to a relevant exception.

0 comments on commit df27a43

Please sign in to comment.