- Fixed bug with union() when applied to non-Table connected
select statements
+ - improved behavior of text() expressions when used as
+ FROM clauses, such as select().select_from(text("sometext"))
+ [ticket:1014]
+
- engines
- Pool listeners can now be provided as a dictionary of
callables or a (possibly partial) duck-type of
def _populate_column_collection(self):
pass
-class _TextFromClause(FromClause):
- __visit_name__ = 'fromclause'
-
- def __init__(self, text):
- self.name = text
-
class _BindParamClause(ClauseElement, _CompareMixin):
"""Represent a bind parameter.
_bind_params_regex = re.compile(r'(?<![:\w\x5c]):(\w+)(?!:)', re.UNICODE)
+ _hide_froms = []
+ oid_column = None
+
def __init__(self, text = "", bind=None, bindparams=None, typemap=None, autocommit=False):
self._bind = bind
self.bindparams = {}
def _get_from_objects(self, **modifiers):
return []
-
+
def supports_execution(self):
return True
if from_obj:
self._froms = util.Set([
- _is_literal(f) and _TextFromClause(f) or f
+ _is_literal(f) and _TextClause(f) or f
for f in util.to_list(from_obj)
])
else:
s = self._generate()
if _is_literal(fromclause):
- fromclause = _TextFromClause(fromclause)
+ fromclause = _TextClause(fromclause)
s._froms = s._froms.union([fromclause])
return s
"""
if _is_literal(fromclause):
- fromclause = _TextFromClause(fromclause)
+ fromclause = _TextClause(fromclause)
self._froms = self._froms.union([fromclause])
),
"SELECT t.myid, t.name, t.description, foo.f FROM mytable AS t, (select f from bar where lala=heyhey) foo WHERE foo.f = t.id")
+ # test Text embedded within select_from(), using binds
+ generate_series = text("generate_series(:x, :y, :z) as s(a)", bindparams=[bindparam('x'), bindparam('y'), bindparam('z')])
+
+ s =select([(func.current_date() + literal_column("s.a")).label("dates")]).select_from(generate_series)
+ self.assert_compile(s, "SELECT CURRENT_DATE + s.a AS dates FROM generate_series(:x, :y, :z) as s(a)", checkparams={'y': None, 'x': None, 'z': None})
+
+ self.assert_compile(s.params(x=5, y=6, z=7), "SELECT CURRENT_DATE + s.a AS dates FROM generate_series(:x, :y, :z) as s(a)", checkparams={'y': 6, 'x': 5, 'z': 7})
+
+
def test_literal(self):
self.assert_compile(select([literal("foo") + literal("bar")], from_obj=[table1]),
"SELECT :param_1 || :param_2 AS anon_1 FROM mytable")
s = select([table1], or_(table1.c.myid==7, table1.c.myid==8, table1.c.myid==bindparam('myid_1')))
self.assertRaisesMessage(exceptions.CompileError, "conflicts with unique bind parameter of the same name", str, s)
+
+
def test_bind_as_col(self):
t = table('foo', column('id'))