summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2005-10-01 18:42:33 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2005-10-01 18:42:33 +0000
commit595e11015fe6809a56a803bda8f79b784c35e555 (patch)
tree221bfa591e60cfdf05da86beba6741f2eb7d75fb /lib/sqlalchemy/sql.py
parent67ccdb8882ed17ecff2c9168d0390045f12ae4fd (diff)
downloadsqlalchemy-595e11015fe6809a56a803bda8f79b784c35e555.tar.gz
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r--lib/sqlalchemy/sql.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index 3887c63b5..dfa3cdbf4 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -218,13 +218,23 @@ class ClauseElement(object):
return self
- def compile(self, engine, bindparams = None):
+ def compile(self, engine = None, bindparams = None):
"""compiles this SQL expression using its underlying SQLEngine to produce
a Compiled object. The actual SQL statement is the Compiled object's string representation.
bindparams is an optional dictionary representing the bind parameters to be used with
the statement. Currently, only the compilations of INSERT and UPDATE statements
use the bind parameters, in order to determine which
table columns should be used in the statement."""
+
+ if engine is None:
+ for f in self._get_from_objects():
+ engine = f.engine
+ if engine is not None: break
+ else:
+ import sqlalchemy.ansisql as ansisql
+ engine = ansisql.engine()
+ #raise "no engine supplied, and no engine could be located within the clauses!"
+
return engine.compile(self, bindparams = bindparams)
def execute(self, *multiparams, **params):
@@ -317,7 +327,7 @@ class TextClause(ClauseElement):
def __init__(self, text = ""):
self.text = text
self.parens = False
-
+
def accept_visitor(self, visitor): visitor.visit_textclause(self)
def hash_key(self):