MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / define_tables

Method define_tables

test/orm/test_unitofwork.py:1063–1132  ·  view source on GitHub ↗
(cls, metadata)

Source from the content-addressed store, hash-verified

1061
1062 @classmethod
1063 def define_tables(cls, metadata):
1064 use_string_defaults = testing.against(
1065 "postgresql", "oracle", "sqlite", "mssql"
1066 )
1067
1068 if use_string_defaults:
1069 hohotype = String(30)
1070 hohoval = "im hoho"
1071 althohoval = "im different hoho"
1072 else:
1073 hohotype = Integer
1074 hohoval = 9
1075 althohoval = 15
1076
1077 cls.other["hohoval"] = hohoval
1078 cls.other["althohoval"] = althohoval
1079
1080 dt = Table(
1081 "default_t",
1082 metadata,
1083 Column(
1084 "id", Integer, primary_key=True, test_needs_autoincrement=True
1085 ),
1086 Column("hoho", hohotype, server_default=str(hohoval)),
1087 Column(
1088 "counter",
1089 Integer,
1090 default=sa.func.char_length("1234567", type_=Integer),
1091 ),
1092 Column(
1093 "foober",
1094 String(30),
1095 default="im foober",
1096 onupdate="im the update",
1097 ),
1098 mysql_engine="MyISAM",
1099 mariadb_engine="MyISAM",
1100 )
1101
1102 st = Table(
1103 "secondary_table",
1104 metadata,
1105 Column(
1106 "id", Integer, primary_key=True, test_needs_autoincrement=True
1107 ),
1108 Column("data", String(50)),
1109 mysql_engine="MyISAM",
1110 mariadb_engine="MyISAM",
1111 )
1112
1113 if testing.against("postgresql", "oracle"):
1114 dt.append_column(
1115 Column(
1116 "secondary_id",
1117 Integer,
1118 normalize_sequence(config, sa.Sequence("sec_id_seq")),
1119 unique=True,
1120 )

Callers

nothing calls this directly

Calls 8

append_columnMethod · 0.95
StringClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
normalize_sequenceFunction · 0.90
ForeignKeyClass · 0.90
char_lengthMethod · 0.80
againstMethod · 0.45

Tested by

no test coverage detected