MCPcopy
hub / github.com/psycopg/psycopg / join

Method join

psycopg/psycopg/sql.py:152–174  ·  view source on GitHub ↗

Return a new `!Composed` interposing the `!joiner` with the `!Composed` items. The `!joiner` must be a `SQL` or a string which will be interpreted as an `SQL`. Example:: >>> fields = sql.Identifier('foo') + sql.Identifier('bar') # a Composed

(self, joiner: SQL | LiteralString)

Source from the content-addressed store, hash-verified

150 return NotImplemented
151
152 def join(self, joiner: SQL | LiteralString) -> Composed:
153 """
154 Return a new `!Composed` interposing the `!joiner` with the `!Composed` items.
155
156 The `!joiner` must be a `SQL` or a string which will be interpreted as
157 an `SQL`.
158
159 Example::
160
161 >>> fields = sql.Identifier('foo') + sql.Identifier('bar') # a Composed
162 >>> print(fields.join(', ').as_string(conn))
163 "foo", "bar"
164
165 """
166 if isinstance(joiner, str):
167 joiner = SQL(joiner)
168 elif not isinstance(joiner, SQL):
169 raise TypeError(
170 "Composed.join() argument must be strings or SQL,"
171 f" got {joiner!r} instead"
172 )
173
174 return joiner.join(self._obj)
175
176
177class SQL(Composable):

Callers 2

test_joinMethod · 0.95
test_auto_literalMethod · 0.95

Calls 2

joinMethod · 0.95
SQLClass · 0.85

Tested by 2

test_joinMethod · 0.76
test_auto_literalMethod · 0.76