summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/sqlsoup.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-01-21 20:52:37 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2010-01-21 20:52:37 +0000
commit8301a266b5dea59226000e53d9e57afd0c775bb9 (patch)
treef3cb3cc69a6ae662b07e3d952f0b0977a9771c5c /lib/sqlalchemy/ext/sqlsoup.py
parent196284c083fc26c5ea87229f9e956f6584d27cc5 (diff)
downloadsqlalchemy-8301a266b5dea59226000e53d9e57afd0c775bb9.tar.gz
send along the sqlsoup engine for encoding purposes.
Diffstat (limited to 'lib/sqlalchemy/ext/sqlsoup.py')
-rw-r--r--lib/sqlalchemy/ext/sqlsoup.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/sqlalchemy/ext/sqlsoup.py b/lib/sqlalchemy/ext/sqlsoup.py
index 6b977102c..5377fee35 100644
--- a/lib/sqlalchemy/ext/sqlsoup.py
+++ b/lib/sqlalchemy/ext/sqlsoup.py
@@ -395,14 +395,15 @@ def _selectable_name(selectable):
x = x[1:]
return x
-def class_for_table(session, selectable, **mapper_kwargs):
+def _class_for_table(session, engine, selectable, **mapper_kwargs):
selectable = expression._clause_element_as_expr(selectable)
mapname = 'Mapped' + _selectable_name(selectable)
# Py2K
if isinstance(mapname, unicode):
- engine_encoding = selectable.metadata.bind.dialect.encoding
+ engine_encoding = engine.dialect.encoding
mapname = mapname.encode(engine_encoding)
# end Py2K
+
if isinstance(selectable, Table):
klass = TableClassType(mapname, (object,), {})
else:
@@ -457,11 +458,11 @@ class SqlSoup(object):
self._cache = {}
self.schema = None
-
+
+ @property
def engine(self):
return self._metadata.bind
- engine = property(engine)
bind = engine
def delete(self, *args, **kwargs):
@@ -502,7 +503,7 @@ class SqlSoup(object):
try:
t = self._cache[selectable]
except KeyError:
- t = class_for_table(self.session, selectable, **kwargs)
+ t = _class_for_table(self.session, self.engine, selectable, **kwargs)
self._cache[selectable] = t
return t
@@ -525,7 +526,7 @@ class SqlSoup(object):
if not table.primary_key.columns:
raise PKNotFoundError('table %r does not have a primary key defined [columns: %s]' % (attr, ','.join(table.c.keys())))
if table.columns:
- t = class_for_table(self.session, table)
+ t = _class_for_table(self.session, self.engine, table)
else:
t = None
self._cache[attr] = t