MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / column_valued

Method column_valued

lib/sqlalchemy/sql/functions.py:353–394  ·  view source on GitHub ↗

Return this :class:`_functions.FunctionElement` as a column expression that selects from itself as a FROM clause. E.g.: .. sourcecode:: pycon+sql >>> from sqlalchemy import select, func >>> gs = func.generate_series(1, 5, -1).column_valued()

(
        self, name: Optional[str] = None, joins_implicitly: bool = False
    )

Source from the content-addressed store, hash-verified

351 return new_func.alias(name=name, joins_implicitly=joins_implicitly)
352
353 def column_valued(
354 self, name: Optional[str] = None, joins_implicitly: bool = False
355 ) -> TableValuedColumn[_T]:
356 """Return this :class:`_functions.FunctionElement` as a column expression that
357 selects from itself as a FROM clause.
358
359 E.g.:
360
361 .. sourcecode:: pycon+sql
362
363 >>> from sqlalchemy import select, func
364 >>> gs = func.generate_series(1, 5, -1).column_valued()
365 >>> print(select(gs))
366 {printsql}SELECT anon_1
367 FROM generate_series(:generate_series_1, :generate_series_2, :generate_series_3) AS anon_1
368
369 This is shorthand for::
370
371 gs = func.generate_series(1, 5, -1).alias().column
372
373 :param name: optional name to assign to the alias name that's generated.
374 If omitted, a unique anonymizing name is used.
375
376 :param joins_implicitly: when True, the "table" portion of the column
377 valued function may be a member of the FROM clause without any
378 explicit JOIN to other tables in the SQL query, and no "cartesian
379 product" warning will be generated. May be useful for SQL functions
380 such as ``func.json_array_elements()``.
381
382 .. versionadded:: 1.4.46
383
384 .. seealso::
385
386 :ref:`tutorial_functions_column_valued` - in the :ref:`unified_tutorial`
387
388 :ref:`postgresql_column_valued` - in the :ref:`postgresql_toplevel` documentation
389
390 :meth:`_functions.FunctionElement.table_valued`
391
392 """ # noqa: 501
393
394 return self.alias(name=name, joins_implicitly=joins_implicitly).column
395
396 @util.ro_non_memoized_property
397 def columns(

Callers 11

CoreFixturesClass · 0.80
test_fn_valuedMethod · 0.80
test_complex_jsonb_queryFunction · 0.80
test_plain_old_unnestMethod · 0.80
test_column_valuedMethod · 0.80
test_scalar_stringsMethod · 0.80

Calls 1

aliasMethod · 0.95

Tested by 10

test_fn_valuedMethod · 0.64
test_complex_jsonb_queryFunction · 0.64
test_plain_old_unnestMethod · 0.64
test_column_valuedMethod · 0.64
test_scalar_stringsMethod · 0.64