API Reference¶
Constants¶
DatabaseConnectionType
¶
FrameWorkType
¶
OrmType
¶
WriterClassType
¶
Bases: Enum
Enum for writer class types.
Source code in supabase_pydantic/util/constants.py
WriterConfig
dataclass
¶
Source code in supabase_pydantic/util/constants.py
Dataclasses¶
ColumnInfo
dataclass
¶
Bases: AsDictParent
Column information.
Source code in supabase_pydantic/util/dataclasses.py
has_default
property
¶
Check if the column has a default value.
is_generated
property
¶
Check if the column is auto-generated (identity or serial).
is_user_defined_type()
¶
nullable()
¶
orm_datatype(orm_type=OrmType.PYDANTIC)
¶
Get the datatype for a column.
Source code in supabase_pydantic/util/dataclasses.py
orm_imports(orm_type=OrmType.PYDANTIC)
¶
Get the unique import statements for a column.
Source code in supabase_pydantic/util/dataclasses.py
ConstraintInfo
dataclass
¶
Bases: AsDictParent
Source code in supabase_pydantic/util/dataclasses.py
TableInfo
dataclass
¶
Bases: AsDictParent
Source code in supabase_pydantic/util/dataclasses.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
_get_columns(is_primary=True, sort_results=False)
¶
Private function to get the primary or secondary columns for a table.
Source code in supabase_pydantic/util/dataclasses.py
add_column(column)
¶
add_constraint(constraint)
¶
add_foreign_key(fk)
¶
aliasing_in_columns()
¶
get_primary_columns(sort_results=False)
¶
get_secondary_columns(sort_results=False)
¶
has_unique_constraint()
¶
primary_is_composite()
¶
primary_key()
¶
Get the primary key for a table.
Source code in supabase_pydantic/util/dataclasses.py
sort_and_separate_columns(separate_nullable=False, separate_primary_key=False)
¶
Sort and combine columns based on is_nullable attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
separate_nullable
|
bool
|
Whether to separate nullable and non-nullable columns. |
False
|
separate_primary_key
|
bool
|
Whether to separate primary key and secondary columns. |
False
|
Returns:
Type | Description |
---|---|
SortedColumns
|
A dictionary with keys, nullable, non_nullable, and remaining as keys |
SortedColumns
|
and lists of ColumnInfo objects as values. |
Source code in supabase_pydantic/util/dataclasses.py
table_dependencies()
¶
Abstract Writer Classes¶
AbstractClassWriter
¶
Bases: ABC
Source code in supabase_pydantic/util/writers/abstract_classes.py
column_section(comment_title, columns)
staticmethod
¶
Method to generate a section of columns.
write_class(add_fk=False)
¶
Method to write the complete class definition.
write_columns(add_fk=False)
¶
Method to generate column definitions for the class.
Source code in supabase_pydantic/util/writers/abstract_classes.py
write_definition()
¶
Method to generate the class definition for the class.
Source code in supabase_pydantic/util/writers/abstract_classes.py
write_docs()
abstractmethod
¶
write_foreign_columns(use_base=False)
abstractmethod
¶
Method to generate foreign column definitions for the class.
write_metaclass(metaclasses=None)
abstractmethod
¶
Method to generate the metaclasses for the class.
write_name()
abstractmethod
¶
write_operational_class()
abstractmethod
¶
write_primary_columns()
abstractmethod
¶
Method to generate column definitions for the class.
write_primary_keys()
abstractmethod
¶
Method to generate primary key definitions for the class.
AbstractFileWriter
¶
Bases: ABC
Source code in supabase_pydantic/util/writers/abstract_classes.py
join(strings)
¶
save(overwrite=False)
¶
Method to save the file.
Source code in supabase_pydantic/util/writers/abstract_classes.py
write()
¶
Method to write the complete file.
Source code in supabase_pydantic/util/writers/abstract_classes.py
write_base_classes()
abstractmethod
¶
Method to generate class definitions for the file.
write_custom_classes()
abstractmethod
¶
Method to generate custom class definitions for the file.
write_imports()
abstractmethod
¶
write_operational_classes()
abstractmethod
¶
Method to generate operational class definitions for the file.
Marshaling Logic¶
add_constraints_to_table_details(tables, schema, constraints)
¶
Add constraints to the table details.
Source code in supabase_pydantic/util/marshalers.py
add_foreign_key_info_to_table_details(tables, fk_details)
¶
Add foreign key information to the table details.
Skips foreign keys where either the source or target table is missing. This ensures that all foreign keys have valid relationship types.
Source code in supabase_pydantic/util/marshalers.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
add_relationships_to_table_details(tables, fk_details)
¶
Add relationships to the table details.
Source code in supabase_pydantic/util/marshalers.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
add_user_defined_types_to_tables(tables, schema, enum_types, enum_type_mapping)
¶
Get user defined types and add them to ColumnInfo.
Source code in supabase_pydantic/util/marshalers.py
analyze_bridge_tables(tables)
¶
Analyze if each table is a bridge table.
Source code in supabase_pydantic/util/marshalers.py
analyze_table_relationships(tables)
¶
Analyze table relationships.
Source code in supabase_pydantic/util/marshalers.py
column_name_is_reserved(column_name)
¶
Check if the column name is a reserved keyword or built-in name or starts with model_.
Source code in supabase_pydantic/util/marshalers.py
column_name_reserved_exceptions(column_name)
¶
Check for select exceptions to the reserved column name check.
construct_table_info(column_details, fk_details, constraints, enum_types, enum_type_mapping, schema='public')
¶
Construct TableInfo objects from column and foreign key details.
Source code in supabase_pydantic/util/marshalers.py
determine_relationship_type(source_table, target_table, fk)
¶
Determine the relationship type between two tables based on their constraints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source_table
|
TableInfo
|
The table containing the foreign key |
required |
target_table
|
TableInfo
|
The table being referenced by the foreign key |
required |
fk
|
ForeignKeyInfo
|
The foreign key information |
required |
Returns:
Type | Description |
---|---|
tuple[RelationType, RelationType]
|
A tuple of (forward_type, reverse_type) representing the relationship in both directions |
Source code in supabase_pydantic/util/marshalers.py
get_alias(column_name)
¶
Provide the original column name as an alias for Pydantic.
Source code in supabase_pydantic/util/marshalers.py
get_enum_types(enum_types, schema)
¶
Get enum types.
Source code in supabase_pydantic/util/marshalers.py
get_table_details_from_columns(column_details)
¶
Get the table details from the column details.
Source code in supabase_pydantic/util/marshalers.py
get_unique_columns_from_constraints(constraint)
¶
Get unique columns from constraints.
Source code in supabase_pydantic/util/marshalers.py
get_user_type_mappings(enum_type_mapping, schema)
¶
Get user type mappings.
Source code in supabase_pydantic/util/marshalers.py
is_bridge_table(table)
¶
Check if the table is a bridge table.
Source code in supabase_pydantic/util/marshalers.py
parse_constraint_definition_for_fk(constraint_definition)
¶
Parse the foreign key definition from the constraint.
Source code in supabase_pydantic/util/marshalers.py
standardize_column_name(column_name)
¶
Check if the column name is a reserved keyword or built-in name and replace it if necessary.
Source code in supabase_pydantic/util/marshalers.py
update_column_constraint_definitions(tables)
¶
Update columns with their CHECK constraint definitions.
Source code in supabase_pydantic/util/marshalers.py
update_columns_with_constraints(tables)
¶
Update columns with constraints.