class documentation

class MSSQLCompiler(compiler.SQLCompiler):

Known subclasses: sqlalchemy.databases.mssql.MSSQLStrictCompiler

View In Hierarchy

Undocumented

Method __init__ Construct a new .SQLCompiler object.
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
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 fetch​_clause Undocumented
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​_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

Inherited from SQLCompiler:

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 group​_by​_clause allow dialects to customize how GROUP BY is rendered.
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.
Class Variable ansi​_bind​_rules No summary
Class Variable 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.
Class Variable literal​_execute​_params bindparameter objects that are rendered as literal values at statement execution time.
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)
Instance Variable escaped​_bind​_names Undocumented
Instance Variable has​_out​_parameters if True, there are bindparam() objects that have the isoutparam flag set.
Instance Variable isdelete 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 post​_compile​_params bindparameter objects that are rendered as bound parameter placeholders at statement execution time.
Instance Variable returning holds the "returning" collection of columns if the statement is CRUD and defines returning columns either implicitly or explicitly
Method ​_add​_to​_result​_map Undocumented
Method ​_anonymize Undocumented
Method ​_apply​_numbered​_params Undocumented
Method ​_compose​_select​_body Undocumented
Method ​_create​_result​_map utility method used for unit tests only.
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 ​_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​_parameters​_for​_postcompile handle special post compile parameters.
Method ​_render​_cte​_clause No summary
Method ​_setup​_crud​_hints Undocumented
Method ​_setup​_select​_hints Undocumented
Method ​_setup​_select​_stack Undocumented
Method ​_truncate​_bindparam Undocumented
Method ​_truncated​_identifier Undocumented
Method bindparam​_string Undocumented
Method escape​_literal​_column 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 is​_subquery Undocumented
Method post​_process​_text Undocumented
Method render​_literal​_bindparam Undocumented
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​_fromclause Undocumented
Method visit​_funcfilter Undocumented
Method visit​_function Undocumented
Method visit​_function​_as​_comparison​_op​_binary Undocumented
Method visit​_grouping 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​_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​_ilike​_op​_binary Undocumented
Method visit​_not​_in​_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​_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​_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 ​_default​_stack​_entry Undocumented
Class Variable insert​_prefetch Undocumented
Class Variable update​_prefetch Undocumented
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 ​_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 ​_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 ​_render​_postcompile whether to render out POSTCOMPILE params during the compile phase.
Instance Variable ​_result​_columns Undocumented
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 anon​_map Undocumented
Instance Variable bind​_names Undocumented
Instance Variable binds Undocumented
Instance Variable bindtemplate Undocumented
Instance Variable cache​_key Undocumented
Instance Variable column​_keys Undocumented
Instance Variable compile​_state Optional .CompileState object that maintains additional state used by the compiler.
Instance Variable cte​_positional Undocumented
Instance Variable ctes Undocumented
Instance Variable ctes​_by​_level​_name Undocumented
Instance Variable ctes​_recursive Undocumented
Instance Variable execution​_options Undocumented
Instance Variable for​_executemany Undocumented
Instance Variable from​_linter Undocumented
Instance Variable inline 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 positional Undocumented
Instance Variable stack Undocumented
Instance Variable string Undocumented
Instance Variable truncated​_names 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 current​_executable Return the current 'executable' that is being compiled.
Property params Return the bind param dictionary embedded into this compiled object, for those values that are present.
Property prefetch Undocumented
Property sql​_compiler Return a Compiled that is capable of processing SQL expressions.

Inherited from Compiled (via SQLCompiler):

Method __str__ Return the string text of the generated SQL or DDL.
Method ​_execute​_on​_connection Undocumented
Method process Undocumented
Method visit​_unsupported​_compilation Undocumented
Class Variable ​_cached​_metadata Undocumented
Instance Variable ​_annotations Undocumented
Instance Variable ​_gen​_time Undocumented
Instance Variable can​_execute Undocumented
Instance Variable dialect Undocumented
Instance Variable preparer Undocumented
Instance Variable schema​_translate​_map Undocumented
Instance Variable statement Undocumented
def __init__(self, *args, **kwargs):
Construct a new .SQLCompiler object.
Parameters
*argsUndocumented
**kwargsadditional keyword arguments to be consumed by the superclass.
dialect.Dialect to be used
statement_expression.ClauseElement to be compiled
column​_keysa list of column names to be compiled into an INSERT or UPDATE statement.
for​_executemanywhether 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.
def _check_can_use_fetch_limit(self, select):

Undocumented

def _get_limit_or_fetch(self, select):

Undocumented

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

Undocumented

def _row_limit_clause(self, select, **kw):
MSSQL 2012 supports OFFSET/FETCH operators Use it instead subquery with row_number
def _schema_aliased_table(self, table):

Undocumented

def _use_top(self, select):

Undocumented

def _with_legacy_schema_aliasing(fn):

Undocumented

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

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):
If we have extra froms make sure we render any alias as hint.
def fetch_clause(self, cs, **kwargs):
def for_update_clause(self, select, **kw):
def get_crud_hint_text(self, table, text):
def get_cte_preamble(self, recursive):
def get_from_hint_text(self, table, text):
def get_select_precolumns(self, select, **kw):
MS-SQL puts TOP, it's version of LIMIT here
def label_select_column(self, select, column, asfrom):

Undocumented

def limit_clause(self, cs, **kwargs):
def order_by_clause(self, select, **kw):
allow dialects to customize how ORDER BY is rendered.
def returning_clause(self, stmt, returning_cols):
def translate_select_structure(self, select_stmt, **kwargs):
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):

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.

@_with_legacy_schema_aliasing
def visit_alias(self, alias, **kw):
def visit_binary(self, binary, **kwargs):
Move bind parameters to the right-hand side of an operator, where possible.
def visit_char_length_func(self, fn, **kw):

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

extract_map =

Undocumented

returning_precedes_values: bool =
set to True classwide to generate RETURNING clauses before the VALUES or WHERE clause (i.e. MSSQL)
tablealiases: dict =

Undocumented