MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit_create_index

Method visit_create_index

lib/sqlalchemy/sql/compiler.py:7229–7259  ·  view source on GitHub ↗
(
        self, create, include_schema=False, include_table_schema=True, **kw
    )

Source from the content-addressed store, hash-verified

7227 )
7228
7229 def visit_create_index(
7230 self, create, include_schema=False, include_table_schema=True, **kw
7231 ):
7232 index = create.element
7233 self._verify_index_table(index)
7234 preparer = self.preparer
7235 text = "CREATE "
7236 if index.unique:
7237 text += "UNIQUE "
7238 if index.name is None:
7239 raise exc.CompileError(
7240 "CREATE INDEX requires that the index have a name"
7241 )
7242
7243 text += "INDEX "
7244 if create.if_not_exists:
7245 text += "IF NOT EXISTS "
7246
7247 text += "%s ON %s (%s)" % (
7248 self._prepared_index_name(index, include_schema=include_schema),
7249 preparer.format_table(
7250 index.table, use_schema=include_table_schema
7251 ),
7252 ", ".join(
7253 self.sql_compiler.process(
7254 expr, include_table=False, literal_binds=True
7255 )
7256 for expr in index.expressions
7257 ),
7258 )
7259 return text
7260
7261 def visit_drop_index(self, drop, **kw):
7262 index = drop.element

Callers

nothing calls this directly

Calls 5

_verify_index_tableMethod · 0.95
_prepared_index_nameMethod · 0.95
format_tableMethod · 0.80
joinMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected