Commit ecc2f0e
JSap0914
fix: use kwargs registry directly and store it in model_config
In SQLModelMetaclass.__new__, the registry configuration block had two bugs:
1. config_registry was sourced via get_config("registry"), which reads the
inherited model_config first. Once any parent class sets model_config["registry"]
(as SQLModel itself does), subclasses that pass a custom registry=... kwarg
would silently get the parent's registry instead of their own.
2. model_config["registry"] was assigned config_table (a copy-paste error)
instead of config_registry, so the model_config entry always ended up as
PydanticUndefined rather than the actual registry object.
Fix both by reading directly from kwargs (honoring the kwarg for the class being
defined without inheriting an ancestor's value) and writing the correct variable.
Reproducer:
custom_registry = registry()
class MyBase(SQLModel, registry=custom_registry): pass
# Before: MyBase.model_config["registry"] == PydanticUndefined
# After: MyBase.model_config["registry"] is custom_registry1 parent 7512b96 commit ecc2f0e
2 files changed
Lines changed: 32 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
616 | | - | |
| 616 | + | |
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
620 | | - | |
| 620 | + | |
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments