diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-28 16:27:23 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-28 16:27:23 -0400 |
| commit | 734376130f01d17acc0d6c2d34c1e0f94a1cd1da (patch) | |
| tree | a362ebea6de09e3a138b27052fec856bf9304064 /lib/sqlalchemy/dialects/postgresql | |
| parent | 1321088644c8d845e6e8d96f24c5f841c3bc9e28 (diff) | |
| download | sqlalchemy-734376130f01d17acc0d6c2d34c1e0f94a1cd1da.tar.gz | |
postgresql dialect tests
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql')
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 25 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/psycopg2.py | 27 |
2 files changed, 25 insertions, 27 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 992995434..cd5d9772d 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -188,7 +188,6 @@ underlying CREATE INDEX command, so it *must* be a valid index type for your version of PostgreSQL. """ - import re from ... import sql, schema, exc, util @@ -333,7 +332,7 @@ class UUID(sqltypes.TypeEngine): if self.as_uuid: def process(value): if value is not None: - value = str(value) + value = util.text_type(value) return value return process else: @@ -1419,7 +1418,7 @@ class PGDialect(default.DefaultDialect): query, bindparams=[ sql.bindparam( - 'schema', str(schema.lower()), + 'schema', util.text_type(schema.lower()), type_=sqltypes.Unicode)] ) ) @@ -1435,7 +1434,7 @@ class PGDialect(default.DefaultDialect): "n.oid=c.relnamespace where n.nspname=current_schema() and " "relname=:name", bindparams=[ - sql.bindparam('name', str(table_name), + sql.bindparam('name', util.text_type(table_name), type_=sqltypes.Unicode)] ) ) @@ -1447,9 +1446,9 @@ class PGDialect(default.DefaultDialect): "relname=:name", bindparams=[ sql.bindparam('name', - str(table_name), type_=sqltypes.Unicode), + util.text_type(table_name), type_=sqltypes.Unicode), sql.bindparam('schema', - str(schema), type_=sqltypes.Unicode)] + util.text_type(schema), type_=sqltypes.Unicode)] ) ) return bool(cursor.first()) @@ -1463,7 +1462,7 @@ class PGDialect(default.DefaultDialect): "n.nspname=current_schema() " "and relname=:name", bindparams=[ - sql.bindparam('name', str(sequence_name), + sql.bindparam('name', util.text_type(sequence_name), type_=sqltypes.Unicode) ] ) @@ -1475,10 +1474,10 @@ class PGDialect(default.DefaultDialect): "n.oid=c.relnamespace where relkind='S' and " "n.nspname=:schema and relname=:name", bindparams=[ - sql.bindparam('name', str(sequence_name), + sql.bindparam('name', util.text_type(sequence_name), type_=sqltypes.Unicode), sql.bindparam('schema', - str(schema), type_=sqltypes.Unicode) + util.text_type(schema), type_=sqltypes.Unicode) ] ) ) @@ -1488,9 +1487,9 @@ class PGDialect(default.DefaultDialect): def has_type(self, connection, type_name, schema=None): bindparams = [ sql.bindparam('typname', - str(type_name), type_=sqltypes.Unicode), + util.text_type(type_name), type_=sqltypes.Unicode), sql.bindparam('nspname', - str(schema), type_=sqltypes.Unicode), + util.text_type(schema), type_=sqltypes.Unicode), ] if schema is not None: query = """ @@ -1546,9 +1545,9 @@ class PGDialect(default.DefaultDialect): """ % schema_where_clause # Since we're binding to unicode, table_name and schema_name must be # unicode. - table_name = str(table_name) + table_name = util.text_type(table_name) if schema is not None: - schema = str(schema) + schema = util.text_type(schema) s = sql.text(query, bindparams=[ sql.bindparam('table_name', type_=sqltypes.Unicode), sql.bindparam('schema', type_=sqltypes.Unicode) diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py index 2893a3872..ce06aab05 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py @@ -142,6 +142,7 @@ type. This replaces SQLAlchemy's pure-Python HSTORE coercion which takes effect for other DBAPIs. """ +from __future__ import absolute_import import re import logging @@ -190,22 +191,20 @@ class _PGNumeric(sqltypes.Numeric): class _PGEnum(ENUM): def __init__(self, *arg, **kw): super(_PGEnum, self).__init__(*arg, **kw) -# start Py2K -# if self.convert_unicode: -# self.convert_unicode = "force" -# end Py2K + if util.py2k: + if self.convert_unicode: + self.convert_unicode = "force" class _PGArray(ARRAY): def __init__(self, *arg, **kw): super(_PGArray, self).__init__(*arg, **kw) -# start Py2K -# # FIXME: this check won't work for setups that -# # have convert_unicode only on their create_engine(). -# if isinstance(self.item_type, sqltypes.String) and \ -# self.item_type.convert_unicode: -# self.item_type.convert_unicode = "force" -# end Py2K + if util.py2k: + # FIXME: this check won't work for setups that + # have convert_unicode only on their create_engine(). + if isinstance(self.item_type, sqltypes.String) and \ + self.item_type.convert_unicode: + self.item_type.convert_unicode = "force" class _PGHStore(HSTORE): @@ -294,9 +293,9 @@ class PGIdentifierPreparer_psycopg2(PGIdentifierPreparer): class PGDialect_psycopg2(PGDialect): driver = 'psycopg2' -# start Py2K -# supports_unicode_statements = False -# end Py2K + if util.py2k: + supports_unicode_statements = False + default_paramstyle = 'pyformat' supports_sane_multi_rowcount = False execution_ctx_cls = PGExecutionContext_psycopg2 |
