sqlalchemy :: sql :: compiler :: SQLCompiler :: Class SQLCompiler
[hide private]
[frames] | no frames]

type SQLCompiler


Default implementation of :class:`.Compiled`.

Compiles :class:`.ClauseElement` objects into SQL strings.

Instance Methods [hide private]
 
__init__(self, dialect, statement, column_keys=None, inline=False, **kwargs)
Construct a new :class:`.SQLCompiler` object.
 
_add_to_result_map(self, keyname, name, objects, type_)
 
_anonymize(self, name)
 
_apply_numbered_params(self)
 
_bind_processors(...)
 
_compose_select_body(self, text, select, inner_columns, froms, byfrom, kwargs)
 
_create_result_map(self)
utility method used for unit tests only.
 
_display_froms_for_select(self, select, asfrom, lateral=False)
 
_fallback_column_name(self, column)
 
_format_frame_clause(self, range_, **kw)
 
_generate_generic_binary(self, binary, opstring, eager_grouping=False, **kw)
 
_generate_generic_unary_modifier(self, unary, opstring, **kw)
 
_generate_generic_unary_operator(self, unary, opstring, **kw)
 
_generate_prefixes(self, stmt, prefixes, **kw)
 
_get_operator_dispatch(self, operator_, qualifier1, qualifier2)
 
_init_cte_state(self, *args, **kw)
Initialize collections related to CTEs only if a CTE is located, to save on the overhead of these collections otherwise.
 
_key_getters_for_crud_column(...)
 
_label_select_column(self, select, column, populate_result_map, asfrom, column_clause_args, name=None, within_columns_clause=True)
produce labeled columns present in a select().
 
_like_percent_literal(...)
 
_nested_result(*args, **kwds)
special API to support the use case of 'nested result sets'
 
_process_anon(self, key)
 
_render_cte_clause(self)
 
_setup_crud_hints(self, stmt, table_text)
 
_setup_select_hints(self, select)
 
_setup_select_stack(self, select, entry, asfrom, lateral)
 
_transform_result_map_for_nested_joins(self, select, transformed_select)
 
_transform_select_for_nested_joins(self, select)
Rewrite any "a JOIN (b JOIN c)" expression as "a JOIN (select * from b JOIN c) AS anon", to support databases that can't parse a parenthesized join correctly (i.e.
 
_truncate_bindparam(self, bindparam)
 
_truncated_identifier(self, ident_class, name)
 
bindparam_string(self, name, positional_names=None, **kw)
 
construct_params(self, params=None, _group_number=None, _check=True)
return a dictionary of bind parameter keys and values
 
default_from(self)
Called when a SELECT statement has no froms, and no FROM clause is to be appended.
 
escape_literal_column(self, text)
provide escaping for the literal_column() construct.
 
for_update_clause(self, select, **kw)
 
format_from_hint_text(self, sqltext, table, hint, iscrud)
 
function_argspec(self, func, **kwargs)
 
get_crud_hint_text(self, table, text)
 
get_cte_preamble(self, recursive)
 
get_from_hint_text(self, table, text)
 
get_render_as_alias_suffix(self, alias_name_text)
 
get_select_hint_text(self, byfroms)
 
get_select_precolumns(self, select, **kw)
Called when building a ``SELECT`` statement, position is just before column list.
 
get_statement_hint_text(self, hint_texts)
 
is_subquery(self)
 
limit_clause(self, select, **kw)
 
order_by_clause(self, select, **kw)
 
post_process_text(self, text)
 
render_literal_bindparam(self, bindparam, **kw)
 
render_literal_value(self, value, type_)
Render the value of a bind parameter as a quoted literal.
 
returning_clause(self, stmt, returning_cols)
 
update_from_clause(self, update_stmt, from_table, extra_froms, from_hints, **kw)
Provide a hook to override the generation of an UPDATE..FROM clause.
 
update_limit_clause(self, update_stmt)
Provide a hook for MySQL to add LIMIT to the UPDATE
 
update_tables_clause(self, update_stmt, from_table, extra_froms, **kw)
Provide a hook to override the initial table clause in an UPDATE statement.
 
visit_alias(self, alias, asfrom=False, ashint=False, iscrud=False, fromhints=None, **kwargs)
 
visit_between_op_binary(self, binary, operator, **kw)
 
visit_binary(self, binary, override_operator=None, eager_grouping=False, **kw)
 
visit_bindparam(self, bindparam, within_columns_clause=False, literal_binds=False, skip_bind_expression=False, **kwargs)
 
visit_case(self, clause, **kwargs)
 
visit_cast(self, cast, **kwargs)
 
visit_clauselist(self, clauselist, **kw)
 
visit_column(self, column, add_to_result_map=None, include_table=True, **kwargs)
 
visit_compound_select(self, cs, asfrom=False, parens=True, compound_index=0, **kwargs)
 
visit_contains_op_binary(self, binary, operator, **kw)
 
visit_cte(self, cte, asfrom=False, ashint=False, fromhints=None, **kwargs)
 
visit_custom_op_binary(self, element, operator, **kw)
 
visit_custom_op_unary_modifier(self, element, operator, **kw)
 
visit_custom_op_unary_operator(self, element, operator, **kw)
 
visit_delete(self, delete_stmt, asfrom=False, **kw)
 
visit_endswith_op_binary(self, binary, operator, **kw)
 
visit_extract(self, extract, **kwargs)
 
visit_false(self, expr, **kw)
 
visit_fromclause(self, fromclause, **kwargs)
 
visit_funcfilter(self, funcfilter, **kwargs)
 
visit_function(self, func, add_to_result_map=None, **kwargs)
 
visit_grouping(self, grouping, asfrom=False, **kwargs)
 
visit_ilike_op_binary(self, binary, operator, **kw)
 
visit_index(self, index, **kwargs)
 
visit_insert(self, insert_stmt, asfrom=False, **kw)
 
visit_isfalse_unary_operator(self, element, operator, **kw)
 
visit_istrue_unary_operator(self, element, operator, **kw)
 
visit_join(self, join, asfrom=False, **kwargs)
 
visit_label(self, label, add_to_result_map=None, within_label_clause=False, within_columns_clause=False, render_label_as_label=None, **kw)
 
visit_label_reference(self, element, within_columns_clause=False, **kwargs)
 
visit_lateral(self, lateral, **kw)
 
visit_like_op_binary(self, binary, operator, **kw)
 
visit_next_value_func(self, next_value, **kw)
 
visit_notbetween_op_binary(self, binary, operator, **kw)
 
visit_notcontains_op_binary(self, binary, operator, **kw)
 
visit_notendswith_op_binary(self, binary, operator, **kw)
 
visit_notilike_op_binary(self, binary, operator, **kw)
 
visit_notlike_op_binary(self, binary, operator, **kw)
 
visit_notmatch_op_binary(self, binary, operator, **kw)
 
visit_notstartswith_op_binary(self, binary, operator, **kw)
 
visit_null(self, expr, **kw)
 
visit_over(self, over, **kwargs)
 
visit_release_savepoint(self, savepoint_stmt)
 
visit_rollback_to_savepoint(self, savepoint_stmt)
 
visit_savepoint(self, savepoint_stmt)
 
visit_select(self, select, asfrom=False, parens=True, fromhints=None, compound_index=0, nested_join_translation=False, select_wraps_for=None, lateral=False, **kwargs)
 
visit_sequence(self, sequence)
 
visit_startswith_op_binary(self, binary, operator, **kw)
 
visit_table(self, table, asfrom=False, iscrud=False, ashint=False, fromhints=None, use_schema=True, **kwargs)
 
visit_tablesample(self, tablesample, asfrom=False, **kw)
 
visit_text_as_from(self, taf, compound_index=None, asfrom=False, parens=True, **kw)
 
visit_textclause(self, textclause, **kw)
 
visit_textual_label_reference(self, element, within_columns_clause=False, **kwargs)
 
visit_true(self, expr, **kw)
 
visit_type_coerce(self, type_coerce, **kw)
 
visit_typeclause(self, typeclause, **kw)
 
visit_unary(self, unary, **kw)
 
visit_update(self, update_stmt, asfrom=False, **kw)
 
visit_withingroup(self, withingroup, **kwargs)

Inherited from Compiled: __str__, compile, execute, process, scalar

Inherited from Compiled (private): _execute_on_connection

Class Variables [hide private]
  _default_stack_entry = immutabledict({'asfrom_froms': frozense...
  _ordered_columns = True
  _textual_ordered_columns = False
  ansi_bind_rules = False
  compound_keywords = {symbol('EXCEPT ALL'): 'EXCEPT ALL', symbo...
  extract_map = {'day': 'day', 'dow': 'dow', 'doy': 'doy', 'epoc...
  insert_prefetch = ()
  isdelete = False
  isinsert = False
  isplaintext = False
  isupdate = False
  render_table_with_column_in_update_from = False
  returning = None
  returning_precedes_values = False
  update_prefetch = ()

Inherited from Compiled: execution_options

Inherited from Compiled (private): _cached_metadata

Properties [hide private]
  params
Return the bind param dictionary embedded into this compiled object, for those values that are present.
  prefetch
  sql_compiler
Return a Compiled that is capable of processing SQL expressions.
Method Details [hide private]

__init__(self, dialect, statement, column_keys=None, inline=False, **kwargs)
(Constructor)

 
Construct a new :class:`.SQLCompiler` object.

:param dialect: :class:`.Dialect` to be used

:param statement: :class:`.ClauseElement` to be compiled

:param column_keys:  a list of column names to be compiled into an
 INSERT or UPDATE statement.

:param inline: whether to generate INSERT statements as "inline", e.g.
 not formatted to return any generated defaults

:param kwargs: additional keyword arguments to be consumed by the
 superclass.

Overrides: Compiled.__init__

_transform_select_for_nested_joins(self, select)

 

Rewrite any "a JOIN (b JOIN c)" expression as "a JOIN (select * from b JOIN c) AS anon", to support databases that can't parse a parenthesized join correctly (i.e. sqlite < 3.7.16).

construct_params(self, params=None, _group_number=None, _check=True)

 

return a dictionary of bind parameter keys and values

Overrides: Compiled.construct_params

default_from(self)

 

Called when a SELECT statement has no froms, and no FROM clause is to be appended.

Gives Oracle a chance to tack on a ``FROM DUAL`` to the string output.

render_literal_value(self, value, type_)

 

Render the value of a bind parameter as a quoted literal.

This is used for statement sections that do not accept bind parameters on the target driver/database.

This should be implemented by subclasses using the quoting services of the DBAPI.

update_from_clause(self, update_stmt, from_table, extra_froms, from_hints, **kw)

 

Provide a hook to override the generation of an UPDATE..FROM clause.

MySQL and MSSQL override this.

update_tables_clause(self, update_stmt, from_table, extra_froms, **kw)

 

Provide a hook to override the initial table clause in an UPDATE statement.

MySQL overrides this.


Class Variable Details [hide private]

_default_stack_entry

Value:
immutabledict({'asfrom_froms': frozenset([]), 'correlate_froms': froze\
nset([])})

compound_keywords

Value:
{symbol('EXCEPT ALL'): 'EXCEPT ALL',
 symbol('EXCEPT'): 'EXCEPT',
 symbol('UNION ALL'): 'UNION ALL',
 symbol('INTERSECT ALL'): 'INTERSECT ALL',
 symbol('UNION'): 'UNION',
 symbol('INTERSECT'): 'INTERSECT'}

extract_map

Value:
{'day': 'day',
 'dow': 'dow',
 'doy': 'doy',
 'epoch': 'epoch',
 'hour': 'hour',
 'microseconds': 'microseconds',
 'milliseconds': 'milliseconds',
 'minute': 'minute',
...

Property Details [hide private]

params

Return the bind param dictionary embedded into this compiled object, for those values that are present.

prefetch

sql_compiler

Return a Compiled that is capable of processing SQL expressions.

If this compiler is one, it would likely just return 'self'.