MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / create_table_constraints

Method create_table_constraints

lib/sqlalchemy/sql/compiler.py:6892–6927  ·  view source on GitHub ↗
(
        self, table, _include_foreign_key_constraints=None, **kw
    )

Source from the content-addressed store, hash-verified

6890 return text
6891
6892 def create_table_constraints(
6893 self, table, _include_foreign_key_constraints=None, **kw
6894 ):
6895 # On some DB order is significant: visit PK first, then the
6896 # other constraints (engine.ReflectionTest.testbasic failed on FB2)
6897 constraints = []
6898 if table.primary_key:
6899 constraints.append(table.primary_key)
6900
6901 all_fkcs = table.foreign_key_constraints
6902 if _include_foreign_key_constraints is not None:
6903 omit_fkcs = all_fkcs.difference(_include_foreign_key_constraints)
6904 else:
6905 omit_fkcs = set()
6906
6907 constraints.extend(
6908 [
6909 c
6910 for c in table._sorted_constraints
6911 if c is not table.primary_key and c not in omit_fkcs
6912 ]
6913 )
6914
6915 return ", \n\t".join(
6916 p
6917 for p in (
6918 self.process(constraint)
6919 for constraint in constraints
6920 if (constraint._should_create_for_compiler(self))
6921 and (
6922 not self.dialect.supports_alter
6923 or not getattr(constraint, "use_alter", False)
6924 )
6925 )
6926 if p is not None
6927 )
6928
6929 def visit_drop_table(self, drop, **kw):
6930 text = "\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