MCPcopy Index your code
hub / github.com/webpy/webpy / join

Method join

web/db.py:243–278  ·  view source on GitHub ↗

Joins multiple queries. >>> SQLQuery.join(['a', 'b'], ', ') Optionally, prefix and suffix arguments can be provided. >>> SQLQuery.join(['a', 'b'], ', ', prefix='(', suffix=')') If target argument is provided,

(items, sep=" ", prefix=None, suffix=None, target=None)

Source from the content-addressed store, hash-verified

241 return [i.value for i in self.items if isinstance(i, SQLParam)]
242
243 def join(items, sep=" ", prefix=None, suffix=None, target=None):
244 """
245 Joins multiple queries.
246
247 >>> SQLQuery.join(['a', 'b'], ', ')
248 <sql: 'a, b'>
249
250 Optionally, prefix and suffix arguments can be provided.
251
252 >>> SQLQuery.join(['a', 'b'], ', ', prefix='(', suffix=')')
253 <sql: '(a, b)'>
254
255 If target argument is provided, the items are appended to target
256 instead of creating a new SQLQuery.
257 """
258 if target is None:
259 target = SQLQuery()
260
261 target_items = target.items
262
263 if prefix:
264 target_items.append(prefix)
265
266 for i, item in enumerate(items):
267 if i != 0 and sep != "":
268 target_items.append(sep)
269 if isinstance(item, SQLQuery):
270 target_items.extend(item.items)
271 elif item == "": # joins with empty strings
272 continue
273 else:
274 target_items.append(item)
275
276 if suffix:
277 target_items.append(suffix)
278 return target
279
280 join = staticmethod(join)
281

Callers 15

recurse_overFunction · 0.80
_makedoc.pyFile · 0.80
test_stopsimpleserverMethod · 0.80
GETMethod · 0.80
test_layers_unicodeMethod · 0.80
test_layers_bytesMethod · 0.80
test_unicode_urlMethod · 0.80
queryMethod · 0.80
sqllistFunction · 0.80
sqlwhereFunction · 0.80
_where_dictMethod · 0.80

Calls 2

SQLQueryClass · 0.85
appendMethod · 0.80

Tested by 6

test_stopsimpleserverMethod · 0.64
GETMethod · 0.64
test_layers_unicodeMethod · 0.64
test_layers_bytesMethod · 0.64
test_unicode_urlMethod · 0.64