summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2005-12-31 07:13:18 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2005-12-31 07:13:18 +0000
commitf3e9dc2c8c611a2dd03e96f13e99894f10820dd0 (patch)
tree64a3fa1207090e0a6b9f26d27182ada3ae96c8f1 /lib/sqlalchemy/engine.py
parent7553b79721c96cdecf87049477ac7c84ef0b0676 (diff)
downloadsqlalchemy-f3e9dc2c8c611a2dd03e96f13e99894f10820dd0.tar.gz
fix to ansisql when it tries to determine param-based select clause that its
only on a column-type object engine has settable 'paramstyle' attribute
Diffstat (limited to 'lib/sqlalchemy/engine.py')
-rw-r--r--lib/sqlalchemy/engine.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/sqlalchemy/engine.py b/lib/sqlalchemy/engine.py
index bc39d90d9..f23701424 100644
--- a/lib/sqlalchemy/engine.py
+++ b/lib/sqlalchemy/engine.py
@@ -176,23 +176,33 @@ class SQLEngine(schema.SchemaEngine):
else:
self.logger = logger
- def _figure_paramstyle(self):
+ def _set_paramstyle(self, style):
+ self._paramstyle = style
+ self._figure_paramstyle(style)
+ paramstyle = property(lambda s:s._paramstyle, _set_paramstyle)
+
+ def _figure_paramstyle(self, paramstyle=None):
db = self.dbapi()
- if db is not None:
- self.paramstyle = db.paramstyle
+ if paramstyle is not None:
+ self._paramstyle = paramstyle
+ elif db is not None:
+ self._paramstyle = db.paramstyle
else:
- self.paramstyle = 'named'
+ self._paramstyle = 'named'
- if self.paramstyle == 'named':
+ if self._paramstyle == 'named':
self.bindtemplate = ':%s'
self.positional=False
- elif self.paramstyle =='pyformat':
+ elif self._paramstyle == 'pyformat':
self.bindtemplate = "%%(%s)s"
self.positional=False
- else:
- # for positional, use pyformat until the end
+ elif self._paramstyle == 'qmark' or self._paramstyle == 'format' or self._paramstyle == 'numeric':
+ # for positional, use pyformat internally, ANSICompiler will convert
+ # to appropriate character upon compilation
self.bindtemplate = "%%(%s)s"
- self.positional=True
+ self.positional = True
+ else:
+ raise "Unsupported paramstyle '%s'" % self._paramstyle
def type_descriptor(self, typeobj):
"""provides a database-specific TypeEngine object, given the generic object