Select would fail if a selectable were passed.
[ticket:2270]. However, the FROM behavior is
still incorrect here, so you need 0.7 in
any case for this use case to be usable.
when used with certain dialects. This
bug is not in 0.7.
+ - Fixed bug whereby with_only_columns() method of
+ Select would fail if a selectable were passed.
+ [ticket:2270]. However, the FROM behavior is
+ still incorrect here, so you need 0.7 in
+ any case for this use case to be usable.
+
- schema
- Added an informative error message when
ForeignKeyConstraint refers to a column name in
with the given columns.
"""
-
- self._raw_columns = [
- isinstance(c, _ScalarSelect) and
- c.self_group(against=operators.comma_op) or c
- for c in [_literal_as_column(c) for c in columns]
- ]
+ rc = []
+ for c in columns:
+ c = _literal_as_column(c)
+ if isinstance(c, _ScalarSelect):
+ c = c.self_group(against=operators.comma_op)
+ rc.append(c)
+ self._raw_columns = rc
@_generative
def where(self, whereclause):
sel3 = visitors.ReplacingCloningVisitor().traverse(sel2)
assert sel3.corresponding_column(col) is sel3.c.foo
+ def test_with_only_generative(self):
+ s1 = table1.select().as_scalar()
+ s2 = table1.select().as_scalar()
+ self.assert_compile(
+ s1.with_only_columns([s2]),
+ # this is the wrong SQL - 0.7 does it correctly.
+ # but the test here at the moment is just that with_only_columns()
+ # doesn't try to evaluate the selectable as a boolean.
+ "SELECT (SELECT table1.col1, table1.col2, "
+ "table1.col3, table1.colx FROM table1) AS anon_1 FROM table1"
+ )
+
def test_select_on_table(self):
sel = select([table1, table2], use_labels=True)