class documentation

Undocumented

Method __init__ Construct a new :class:`.SQLCompiler` object.
Method delete_extra_from_clause Render the DELETE .. FROM clause specific to MSSQL.
Method delete_table_clause If we have extra froms make sure we render any alias as hint.
Method for_update_clause Undocumented
Method get_crud_hint_text Undocumented
Method get_cte_preamble Undocumented
Method get_from_hint_text Undocumented
Method get_select_precolumns MS-SQL puts TOP, it's version of LIMIT here
Method label_select_column Undocumented
Method limit_clause Undocumented
Method order_by_clause allow dialects to customize how ORDER BY is rendered.
Method returning_clause Undocumented
Method translate_select_structure Look for ``LIMIT`` and OFFSET in a select statement, and if so tries to wrap it in a subquery with ``row_number()`` criterion. MSSQL 2012 and above are excluded
Method update_from_clause Render the UPDATE..FROM clause specific to MSSQL.
Method visit_alias Undocumented
Method visit_binary Move bind parameters to the right-hand side of an operator, where possible.
Method visit_char_length_func Undocumented
Method visit_column Undocumented
Method visit_concat_op_binary Undocumented
Method visit_concat_op_expression_clauselist Undocumented
Method visit_current_date_func Undocumented
Method visit_empty_set_expr Undocumented
Method visit_extract Undocumented
Method visit_false Undocumented
Method visit_is_distinct_from_binary Undocumented
Method visit_is_not_distinct_from_binary Undocumented
Method visit_json_getitem_op_binary Undocumented
Method visit_json_path_getitem_op_binary Undocumented
Method visit_length_func Undocumented
Method visit_match_op_binary Undocumented
Method visit_now_func Undocumented
Method visit_rollback_to_savepoint Undocumented
Method visit_savepoint Undocumented
Method visit_sequence Undocumented
Method visit_table Undocumented
Method visit_true Undocumented
Method visit_try_cast Undocumented
Class Variable extract_map Undocumented
Class Variable returning_precedes_values set to True classwide to generate RETURNING clauses before the VALUES or WHERE clause (i.e. MSSQL)
Instance Variable tablealiases Undocumented
Method _check_can_use_fetch_limit Undocumented
Method _get_limit_or_fetch Undocumented
Method _render_json_extract_from_binary Undocumented
Method _row_limit_clause MSSQL 2012 supports OFFSET/FETCH operators Use it instead subquery with row_number
Method _schema_aliased_table Undocumented
Method _use_top Undocumented
Method _with_legacy_schema_aliasing Undocumented

Inherited from SQLCompiler:

Method bindparam_string Undocumented
Method construct_expanded_state Return a new :class:`.ExpandedState` for a given parameter set.
Method construct_params return a dictionary of bind parameter keys and values
Method default_from Called when a SELECT statement has no froms, and no FROM clause is to be appended.
Method escape_literal_column Undocumented
Method fetch_clause Undocumented
Method format_from_hint_text Undocumented
Method function_argspec Undocumented
Method get_render_as_alias_suffix Undocumented
Method get_select_hint_text Undocumented
Method get_statement_hint_text Undocumented
Method group_by_clause allow dialects to customize how GROUP BY is rendered.
Method is_subquery Undocumented
Method post_process_text Undocumented
Method render_bind_cast Undocumented
Method render_literal_bindparam Undocumented
Method render_literal_value Render the value of a bind parameter as a quoted literal.
Method update_limit_clause Provide a hook for MySQL to add LIMIT to the UPDATE
Method update_tables_clause Provide a hook to override the initial table clause in an UPDATE statement.
Method visit_between_op_binary Undocumented
Method visit_bindparam Undocumented
Method visit_case Undocumented
Method visit_cast Undocumented
Method visit_clauselist Undocumented
Method visit_collation Undocumented
Method visit_compound_select Undocumented
Method visit_contains_op_binary Undocumented
Method visit_cte Undocumented
Method visit_custom_op_binary Undocumented
Method visit_custom_op_unary_modifier Undocumented
Method visit_custom_op_unary_operator Undocumented
Method visit_delete Undocumented
Method visit_empty_set_op_expr Undocumented
Method visit_endswith_op_binary Undocumented
Method visit_expression_clauselist Undocumented
Method visit_floordiv_binary Undocumented
Method visit_fromclause Undocumented
Method visit_funcfilter Undocumented
Method visit_function Undocumented
Method visit_function_as_comparison_op_binary Undocumented
Method visit_grouping Undocumented
Method visit_icontains_op_binary Undocumented
Method visit_iendswith_op_binary Undocumented
Method visit_ilike_case_insensitive_operand Undocumented
Method visit_ilike_op_binary Undocumented
Method visit_index Undocumented
Method visit_insert Undocumented
Method visit_is_false_unary_operator Undocumented
Method visit_is_true_unary_operator Undocumented
Method visit_istartswith_op_binary Undocumented
Method visit_join Undocumented
Method visit_label Undocumented
Method visit_label_reference Undocumented
Method visit_lambda_element Undocumented
Method visit_lateral Undocumented
Method visit_like_op_binary Undocumented
Method visit_mod_binary Undocumented
Method visit_next_value_func Undocumented
Method visit_not_between_op_binary Undocumented
Method visit_not_contains_op_binary Undocumented
Method visit_not_endswith_op_binary Undocumented
Method visit_not_icontains_op_binary Undocumented
Method visit_not_iendswith_op_binary Undocumented
Method visit_not_ilike_op_binary Undocumented
Method visit_not_in_op_binary Undocumented
Method visit_not_istartswith_op_binary Undocumented
Method visit_not_like_op_binary Undocumented
Method visit_not_match_op_binary Undocumented
Method visit_not_regexp_match_op_binary Undocumented
Method visit_not_startswith_op_binary Undocumented
Method visit_null Undocumented
Method visit_over Undocumented
Method visit_regexp_match_op_binary Undocumented
Method visit_regexp_replace_op_binary Undocumented
Method visit_release_savepoint Undocumented
Method visit_scalar_function_column Undocumented
Method visit_scalar_values Undocumented
Method visit_select Undocumented
Method visit_select_statement_grouping Undocumented
Method visit_startswith_op_binary Undocumented
Method visit_subquery Undocumented
Method visit_table_valued_alias Undocumented
Method visit_table_valued_column Undocumented
Method visit_tablesample Undocumented
Method visit_textclause Undocumented
Method visit_textual_label_reference Undocumented
Method visit_textual_select Undocumented
Method visit_truediv_binary Undocumented
Method visit_tuple Undocumented
Method visit_type_coerce Undocumented
Method visit_typeclause Undocumented
Method visit_unary Undocumented
Method visit_update Undocumented
Method visit_values Undocumented
Method visit_withingroup Undocumented
Class Variable ansi_bind_rules SQL 92 doesn't allow bind parameters to be used in the columns clause of a SELECT, nor does it allow ambiguous expressions like "? = ?". A compiler subclass can set this flag to False if the target driver/DB enforces this...
Class Variable bindname_escape_characters A mapping (e.g. dict or similar) containing a lookup of characters keyed to replacement characters which will be applied to all 'bind names' used in SQL statements as a form of 'escaping'; the given characters are replaced entirely with the 'replacement' character when rendered in the SQL statement, and a similar translation is performed on the incoming names used in parameter dictionaries passed to methods like :meth:`_engine...
Class Variable implicit_returning list of "implicit" returning columns for a toplevel INSERT or UPDATE statement, used to receive newly generated values of columns.
Class Variable insert_prefetch list of columns for which default values should be evaluated before an INSERT takes place
Class Variable is_sql Undocumented
Class Variable literal_execute_params bindparameter objects that are rendered as literal values at statement execution time.
Class Variable post_compile_params bindparameter objects that are rendered as bound parameter placeholders at statement execution time.
Class Variable postfetch list of columns that can be post-fetched after INSERT or UPDATE to receive server-updated values
Class Variable postfetch_lastrowid if True, and this in insert, use cursor.lastrowid to populate result.inserted_primary_key.
Class Variable render_table_with_column_in_update_from set to True classwide to indicate the SET clause in a multi-table UPDATE statement should qualify columns with the table name (i.e. MySQL only)
Class Variable update_prefetch list of columns for which onupdate default values should be evaluated before an UPDATE takes place
Instance Variable anon_map Undocumented
Instance Variable bind_names a dictionary of BindParameter instances to "compiled" names that are actually present in the generated SQL
Instance Variable binds a dictionary of bind parameter keys to BindParameter instances.
Instance Variable bindtemplate template to render bound parameters based on paramstyle.
Instance Variable cache_key The :class:`.CacheKey` that was generated ahead of creating this :class:`.Compiled` object.
Instance Variable column_keys Undocumented
Instance Variable compilation_bindtemplate template used by compiler to render parameters before positional paramstyle application
Instance Variable compile_state Optional :class:`.CompileState` object that maintains additional state used by the compiler.
Instance Variable ctes Undocumented
Instance Variable ctes_by_level_name Undocumented
Instance Variable ctes_recursive Undocumented
Instance Variable dml_compile_state Optional :class:`.CompileState` assigned at the same point that .isinsert, .isupdate, or .isdelete is assigned.
Instance Variable escaped_bind_names Undocumented
Instance Variable for_executemany Undocumented
Instance Variable from_linter Undocumented
Instance Variable has_out_parameters if True, there are bindparam() objects that have the isoutparam flag set.
Instance Variable inline Undocumented
Instance Variable isdelete Undocumented
Instance Variable isinsert Undocumented
Instance Variable isplaintext Undocumented
Instance Variable isupdate class-level defaults which can be set at the instance level to define if this Compiled instance represents INSERT/UPDATE/DELETE
Instance Variable label_length Undocumented
Instance Variable level_name_by_cte Undocumented
Instance Variable linting Undocumented
Instance Variable next_numeric_pos Undocumented
Instance Variable positional Undocumented
Instance Variable positiontup for a compiled construct that uses a positional paramstyle, will be a sequence of strings, indicating the names of bound parameters in order.
Instance Variable stack major statements such as SELECT, INSERT, UPDATE, DELETE are tracked in this stack using an entry format.
Instance Variable string The string representation of the ``statement``
Instance Variable truncated_names Undocumented
Property current_executable Return the current 'executable' that is being compiled.
Property effective_returning The effective "returning" columns for INSERT, UPDATE or DELETE.
Property insert_single_values_expr When an INSERT is compiled with a single set of parameters inside a VALUES expression, the string is assigned here, where it can be used for insert batching schemes to rewrite the VALUES expression.
Property params Return the bind param dictionary embedded into this compiled object, for those values that are present.
Property prefetch Undocumented
Property returning backwards compatibility; returns the effective_returning collection.
Property sql_compiler Return a Compiled that is capable of processing SQL expressions.
Class Method _init_bind_translate Undocumented
Class Method _init_compiler_cls Undocumented
Method _add_to_result_map Undocumented
Method _anonymize Undocumented
Method _compose_select_body Undocumented
Method _create_result_map utility method used for unit tests only.
Method _deliver_insertmanyvalues_batches Undocumented
Method _dispatch_independent_ctes Undocumented
Method _display_froms_for_select Undocumented
Method _fallback_column_name Undocumented
Method _format_frame_clause Undocumented
Method _generate_delimited_and_list Undocumented
Method _generate_delimited_list Undocumented
Method _generate_generic_binary Undocumented
Method _generate_generic_unary_modifier Undocumented
Method _generate_generic_unary_operator Undocumented
Method _generate_prefixes Undocumented
Method _get_operator_dispatch Undocumented
Method _get_set_input_sizes_lookup Undocumented
Method _init_cte_state Initialize collections related to CTEs only if a CTE is located, to save on the overhead of these collections otherwise.
Method _insert_stmt_should_use_insertmanyvalues Undocumented
Method _label_returning_column Render a column with necessary labels inside of a RETURNING clause.
Method _label_select_column produce labeled columns present in a select().
Method _literal_execute_expanding_parameter Undocumented
Method _literal_execute_expanding_parameter_literal_binds Undocumented
Method _nested_result special API to support the use case of 'nested result sets'
Method _process_numeric Undocumented
Method _process_parameters_for_postcompile handle special post compile parameters.
Method _process_positional Undocumented
Method _render_cte_clause include_following_stack Also render the nesting CTEs on the next stack. Useful for SQL structures like UNION or INSERT that can wrap SELECT statements containing nesting CTEs.
Method _render_values Undocumented
Method _setup_crud_hints Undocumented
Method _setup_select_hints Undocumented
Method _setup_select_stack Undocumented
Method _truncate_bindparam Undocumented
Method _truncated_identifier Undocumented
Class Variable _bind_translate_chars Undocumented
Class Variable _bind_translate_re Undocumented
Class Variable _default_stack_entry Undocumented
Class Variable _get_bind_name_for_col Undocumented
Class Variable _insert_crud_params Undocumented
Class Variable _positional_pattern Undocumented
Class Variable _post_compile_pattern Undocumented
Class Variable _pyformat_pattern Undocumented
Class Variable _values_bindparam Undocumented
Class Variable _visited_bindparam Undocumented
Instance Variable _ad_hoc_textual tell the result that we encountered text() or '*' constructs in the middle of the result columns, but we also have compiled columns, so if the number of columns in cursor.description does not match how many expressions we have, that means we can't rely on positional at all and should match on name.
Instance Variable _cache_key_bind_match a mapping that will relate the BindParameter object we compile to those that are part of the extracted collection of parameters in the cache key, if we were given a cache key.
Instance Variable _insertmanyvalues Undocumented
Instance Variable _loose_column_name_matching tell the result object that the SQL statement is textual, wants to match up to Column objects, and may be using the ._tq_label in the SELECT rather than the base name.
Instance Variable _numeric_binds True if paramstyle is "numeric". This paramstyle is trickier than all the others.
Instance Variable _numeric_binds_identifier_char Character that's used to as the identifier of a numerical bind param. For example if this char is set to ``$``, numerical binds will be rendered in the form ``$1, $2, $3``.
Instance Variable _ordered_columns if False, means we can't be sure the list of entries in _result_columns is actually the rendered order. Usually True unless using an unordered TextualSelect.
Instance Variable _post_compile_expanded_state When render_postcompile is used, the ``ExpandedState`` used to create the "expanded" SQL is assigned here, and then used by the ``.params`` accessor and ``.construct_params()`` methods for their return values.
Instance Variable _pre_expanded_positiontup Undocumented
Instance Variable _pre_expanded_string Stores the original string SQL before 'post_compile' is applied, for cases where 'post_compile' were used.
Instance Variable _render_postcompile whether to render out POSTCOMPILE params during the compile phase.
Instance Variable _result_columns relates label names in the final SQL to a tuple of local column/label name, ColumnElement object (if any) and TypeEngine. CursorResult uses this for type processing and column targeting
Instance Variable _textual_ordered_columns tell the result object that the column names as rendered are important, but they are also "ordered" vs. what is in the compiled object here.
Instance Variable _truncated_counters Undocumented
Property _bind_processors Undocumented
Property _global_attributes Undocumented
Property _inserted_primary_key_from_lastrowid_getter Undocumented
Property _inserted_primary_key_from_returning_getter Undocumented
Property _like_percent_literal Undocumented
Property _within_exec_param_key_getter Undocumented

Inherited from Compiled (via SQLCompiler):

Method __init_subclass__ Undocumented
Method __str__ Return the string text of the generated SQL or DDL.
Method process Undocumented
Method visit_unsupported_compilation Undocumented
Class Variable is_ddl Undocumented
Instance Variable can_execute Undocumented
Instance Variable dialect Undocumented
Instance Variable execution_options Undocumented
Instance Variable preparer Undocumented
Instance Variable schema_translate_map Execution options propagated from the statement. In some cases, sub-elements of the statement can modify these.
Instance Variable state description of the compiler's state
Instance Variable statement The statement to compile.
Method _execute_on_connection Undocumented
Class Variable _cached_metadata Undocumented
Instance Variable _annotations Undocumented
Instance Variable _gen_time Generation time of this :class:`.Compiled`, used for reporting cache stats.
def __init__(self, *args, **kwargs): (source)

Construct a new :class:`.SQLCompiler` object. :param dialect: :class:`.Dialect` to be used :param statement: :class:`_expression.ClauseElement` to be compiled :param column_keys: a list of column names to be compiled into an INSERT or UPDATE statement. :param for_executemany: whether INSERT / UPDATE statements should expect that they are to be invoked in an "executemany" style, which may impact how the statement will be expected to return the values of defaults and autoincrement / sequences and similar. Depending on the backend and driver in use, support for retrieving these values may be disabled which means SQL expressions may be rendered inline, RETURNING may not be rendered, etc. :param kwargs: additional keyword arguments to be consumed by the superclass.

def delete_extra_from_clause(self, delete_stmt, from_table, extra_froms, from_hints, **kw): (source)

Render the DELETE .. FROM clause specific to MSSQL. Yes, it has the FROM keyword twice.

def delete_table_clause(self, delete_stmt, from_table, extra_froms): (source)

If we have extra froms make sure we render any alias as hint.

def for_update_clause(self, select, **kw): (source)
def get_crud_hint_text(self, table, text): (source)
def get_cte_preamble(self, recursive): (source)
def get_from_hint_text(self, table, text): (source)
def get_select_precolumns(self, select, **kw): (source)

MS-SQL puts TOP, it's version of LIMIT here

def label_select_column(self, select, column, asfrom): (source)

Undocumented

def limit_clause(self, cs, **kwargs): (source)
def order_by_clause(self, select, **kw): (source)

allow dialects to customize how ORDER BY is rendered.

def returning_clause(self, stmt, returning_cols, *, populate_result_map, **kw): (source)
def translate_select_structure(self, select_stmt, **kwargs): (source)

Look for ``LIMIT`` and OFFSET in a select statement, and if so tries to wrap it in a subquery with ``row_number()`` criterion. MSSQL 2012 and above are excluded

def update_from_clause(self, update_stmt, from_table, extra_froms, from_hints, **kw): (source)

Render the UPDATE..FROM clause specific to MSSQL. In MSSQL, if the UPDATE statement involves an alias of the table to be updated, then the table itself must be added to the FROM list as well. Otherwise, it is optional. Here, we add it regardless.

def visit_binary(self, binary, **kwargs): (source)

Move bind parameters to the right-hand side of an operator, where possible.

def visit_char_length_func(self, fn, **kw): (source)

Undocumented

@_with_legacy_schema_aliasing
def visit_column(self, column, add_to_result_map=None, **kw): (source)
def visit_concat_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_concat_op_expression_clauselist(self, clauselist, operator, **kw): (source)

Undocumented

def visit_current_date_func(self, fn, **kw): (source)

Undocumented

def visit_empty_set_expr(self, type_, **kw): (source)
def visit_extract(self, extract, **kw): (source)
def visit_false(self, expr, **kw): (source)
def visit_is_distinct_from_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_is_not_distinct_from_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_json_getitem_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_json_path_getitem_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_length_func(self, fn, **kw): (source)

Undocumented

def visit_match_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_now_func(self, fn, **kw): (source)

Undocumented

def visit_rollback_to_savepoint(self, savepoint_stmt, **kw): (source)
def visit_savepoint(self, savepoint_stmt, **kw): (source)
def visit_sequence(self, seq, **kw): (source)
@_with_legacy_schema_aliasing
def visit_table(self, table, mssql_aliased=False, iscrud=False, **kwargs): (source)
def visit_true(self, expr, **kw): (source)
def visit_try_cast(self, element, **kw): (source)

Undocumented

extract_map = (source)

Undocumented

returning_precedes_values: bool = (source)

set to True classwide to generate RETURNING clauses before the VALUES or WHERE clause (i.e. MSSQL)

tablealiases: dict = (source)

Undocumented

def _check_can_use_fetch_limit(self, select): (source)

Undocumented

def _get_limit_or_fetch(self, select): (source)

Undocumented

def _render_json_extract_from_binary(self, binary, operator, **kw): (source)

Undocumented

def _row_limit_clause(self, select, **kw): (source)

MSSQL 2012 supports OFFSET/FETCH operators Use it instead subquery with row_number

def _schema_aliased_table(self, table): (source)

Undocumented

def _use_top(self, select): (source)

Undocumented

def _with_legacy_schema_aliasing(fn): (source)

Undocumented