MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / create_table_constraints

Method create_table_constraints

lib/sqlalchemy/sql/compiler.py:7170–7205  ·  lib/sqlalchemy/sql/compiler.py::DDLCompiler.create_table_constraints
(
        self, table, _include_foreign_key_constraints=None, **kw
    )

Source from the content-addressed store, hash-verified

7168 return text
7169
7170 def create_table_constraints(
7171 self, table, _include_foreign_key_constraints=None, **kw
7172 ):
7173 class="cm"># On some DB order is significant: visit PK first, then the
7174 class="cm"># other constraints (engine.ReflectionTest.testbasic failed on FB2)
7175 constraints = []
7176 if table.primary_key:
7177 constraints.append(table.primary_key)
7178
7179 all_fkcs = table.foreign_key_constraints
7180 if _include_foreign_key_constraints is not None:
7181 omit_fkcs = all_fkcs.difference(_include_foreign_key_constraints)
7182 else:
7183 omit_fkcs = set()
7184
7185 constraints.extend(
7186 [
7187 c
7188 for c in table._sorted_constraints
7189 if c is not table.primary_key and c not in omit_fkcs
7190 ]
7191 )
7192
7193 return class="st">", \n\t".join(
7194 p
7195 for p in (
7196 self.process(constraint)
7197 for constraint in constraints
7198 if (constraint._should_create_for_compiler(self))
7199 and (
7200 not self.dialect.supports_alter
7201 or not getattr(constraint, class="st">"use_alter", False)
7202 )
7203 )
7204 if p is not None
7205 )
7206
7207 def visit_drop_table(self, drop, **kw):
7208 text = class="st">"\nDROP TABLE "

Callers 1

visit_create_tableMethod · 0.95

Calls 6

appendMethod · 0.45
differenceMethod · 0.45
extendMethod · 0.45
joinMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected