We declared accepting a sequence of Composable, but, because we passed
the joined values to `Composite`, actually non-composable were
interpreted as `Literal`.
Make this behaviour explicit by testing it and fixing the signature.
return Composed(rv)
- def join(self, seq: Iterable[Composable]) -> Composed:
+ def join(self, seq: Iterable[Any]) -> Composed:
"""
Join a sequence of `Composable`.
- :param seq: the elements to join.
- :type seq: iterable of `!Composable`
+ :param seq: the elements to join. Elements that are not `Composable`
+ will be considered `Literal`.
Use the `!SQL` object's string to separate the elements in `!seq`.
Note that `Composed` objects are iterable too, so they can be used as
assert isinstance(obj, sql.Composed)
assert obj.as_string(conn) == '"foo", bar, 42'
+ obj = sql.SQL(", ").join(["foo", "bar", 42])
+ assert isinstance(obj, sql.Composed)
+ assert obj.as_string(conn) == """'foo', 'bar', 42"""
+
obj = sql.SQL(", ").join([])
assert obj == sql.Composed([])