diff options
Diffstat (limited to 'lib/sqlalchemy/dialects')
| -rw-r--r-- | lib/sqlalchemy/dialects/mssql/base.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/oracle/base.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/sqlite/base.py | 3 |
5 files changed, 21 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index c10b75c02..ec267880c 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -1532,6 +1532,9 @@ class MSSQLCompiler(compiler.SQLCompiler): fromhints=from_hints, **kw) for t in [from_table] + extra_froms) + def visit_empty_set_expr(self, type_): + return 'SELECT 1 WHERE 1!=1' + class MSSQLStrictCompiler(MSSQLCompiler): diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 3aede4a05..2bb5b5beb 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -1114,6 +1114,9 @@ class MySQLCompiler(compiler.SQLCompiler): fromhints=from_hints, **kw) for t in [from_table] + extra_froms) + def visit_empty_set_expr(self, type_): + return 'SELECT 1 FROM (SELECT 1) as _empty_set WHERE 1!=1' + class MySQLDDLCompiler(compiler.DDLCompiler): def get_column_specification(self, column, **kw): diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 356c2a2bf..76ae1ced6 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -909,6 +909,9 @@ class OracleCompiler(compiler.SQLCompiler): def limit_clause(self, select, **kw): return "" + def visit_empty_set_expr(self, type_): + return 'SELECT 1 FROM DUAL WHERE 1!=1' + def for_update_clause(self, select, **kw): if self.is_subquery(): return "" diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index c9270943b..ad15cb0ea 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1485,6 +1485,15 @@ class PGCompiler(compiler.SQLCompiler): if escape else '' ) + def visit_empty_set_expr(self, type_, **kw): + # cast the empty set to the type we are comparing against. if + # we are comparing against the null type, pick an arbitrary + # datatype for the empty set + if type_._isnull: + type_ = INTEGER() + return 'SELECT CAST(NULL AS %s) WHERE 1!=1' % \ + self.dialect.type_compiler.process(type_, **kw) + def render_literal_value(self, value, type_): value = super(PGCompiler, self).render_literal_value(value, type_) diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index cc17b6c9b..345ad901e 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -870,6 +870,9 @@ class SQLiteCompiler(compiler.SQLCompiler): self.process(binary.left, **kw), self.process(binary.right, **kw)) + def visit_empty_set_expr(self, type_): + return 'SELECT 1 FROM (SELECT 1) WHERE 1!=1' + class SQLiteDDLCompiler(compiler.DDLCompiler): |
