activemodel 0.14.1__py3-none-any.whl → 0.15.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@ from sqlmodel._compat import ( # type: ignore[attr-defined]
29
29
  UndefinedType,
30
30
  is_field_noneable,
31
31
  )
32
- from sqlmodel.main import get_sqlalchemy_type
32
+ from sqlmodel.main import get_sqlalchemy_type, _get_sqlmodel_field_value
33
33
 
34
34
  from activemodel.utils import hash_function_code
35
35
 
@@ -43,7 +43,7 @@ if TYPE_CHECKING:
43
43
  # https://github.com/fastapi/sqlmodel/blob/5c2dbe419edc2d15200eee5269c9508987944ed8/sqlmodel/main.py#L691
44
44
  assert (
45
45
  hash_function_code(sqlmodel.main.get_column_from_field)
46
- == "ab3cdd5d20079358911b6aef76b3916ba3890b20eb07e970a0f35bd63e1713d9"
46
+ == "c64e50f8ca8a345ad2543690849a284d5436515835e41c56638cfaba251bc406"
47
47
  ), (
48
48
  f"get_column_from_field has changed, please verify the patch is still valid: {hash_function_code(sqlmodel.main.get_column_from_field)}"
49
49
  )
@@ -51,7 +51,7 @@ assert (
51
51
 
52
52
  def get_column_from_field(field: Any) -> Column: # type: ignore
53
53
  field_info = field
54
- sa_column = getattr(field_info, "sa_column", Undefined)
54
+ sa_column = _get_sqlmodel_field_value(field_info, "sa_column", Undefined)
55
55
  if isinstance(sa_column, Column):
56
56
  # <Change>
57
57
  if not sa_column.comment and (field_comment := field_info.description):
@@ -59,35 +59,35 @@ def get_column_from_field(field: Any) -> Column: # type: ignore
59
59
  # </Change>
60
60
  return sa_column
61
61
  sa_type = get_sqlalchemy_type(field)
62
- primary_key = getattr(field_info, "primary_key", Undefined)
62
+ primary_key = _get_sqlmodel_field_value(field_info, "primary_key", Undefined)
63
63
  if primary_key is Undefined:
64
64
  primary_key = False
65
- index = getattr(field_info, "index", Undefined)
65
+ index = _get_sqlmodel_field_value(field_info, "index", Undefined)
66
66
  if index is Undefined:
67
67
  index = False
68
68
  nullable = not primary_key and is_field_noneable(field)
69
69
  # Override derived nullability if the nullable property is set explicitly
70
70
  # on the field
71
- field_nullable = getattr(field_info, "nullable", Undefined) # noqa: B009
71
+ field_nullable = _get_sqlmodel_field_value(field_info, "nullable", Undefined) # noqa: B009
72
72
  if field_nullable is not Undefined:
73
73
  assert not isinstance(field_nullable, UndefinedType)
74
74
  nullable = field_nullable
75
75
  args = []
76
- foreign_key = getattr(field_info, "foreign_key", Undefined)
76
+ foreign_key = _get_sqlmodel_field_value(field_info, "foreign_key", Undefined)
77
77
  if foreign_key is Undefined:
78
78
  foreign_key = None
79
- unique = getattr(field_info, "unique", Undefined)
79
+ unique = _get_sqlmodel_field_value(field_info, "unique", Undefined)
80
80
  if unique is Undefined:
81
81
  unique = False
82
82
  if foreign_key:
83
- if field_info.ondelete == "SET NULL" and not nullable:
83
+ ondelete_value = _get_sqlmodel_field_value(field_info, "ondelete", Undefined)
84
+ if ondelete_value is Undefined:
85
+ ondelete_value = None
86
+ if ondelete_value == "SET NULL" and not nullable:
84
87
  raise RuntimeError('ondelete="SET NULL" requires nullable=True')
85
88
  assert isinstance(foreign_key, str)
86
- ondelete = getattr(field_info, "ondelete", Undefined)
87
- if ondelete is Undefined:
88
- ondelete = None
89
- assert isinstance(ondelete, (str, type(None))) # for typing
90
- args.append(ForeignKey(foreign_key, ondelete=ondelete))
89
+ assert isinstance(ondelete_value, (str, type(None))) # for typing
90
+ args.append(ForeignKey(foreign_key, ondelete=ondelete_value))
91
91
  kwargs = {
92
92
  "primary_key": primary_key,
93
93
  "nullable": nullable,
@@ -101,10 +101,12 @@ def get_column_from_field(field: Any) -> Column: # type: ignore
101
101
  sa_default = field_info.default
102
102
  if sa_default is not Undefined:
103
103
  kwargs["default"] = sa_default
104
- sa_column_args = getattr(field_info, "sa_column_args", Undefined)
104
+ sa_column_args = _get_sqlmodel_field_value(field_info, "sa_column_args", Undefined)
105
105
  if sa_column_args is not Undefined:
106
106
  args.extend(list(cast(Sequence[Any], sa_column_args)))
107
- sa_column_kwargs = getattr(field_info, "sa_column_kwargs", Undefined)
107
+ sa_column_kwargs = _get_sqlmodel_field_value(
108
+ field_info, "sa_column_kwargs", Undefined
109
+ )
108
110
 
109
111
  # <Change>
110
112
  if field_info.description:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: activemodel
3
- Version: 0.14.1
3
+ Version: 0.15.0
4
4
  Summary: Make SQLModel more like an a real ORM
5
5
  Project-URL: Repository, https://github.com/iloveitaly/activemodel
6
6
  Author-email: Michael Bianco <iloveitaly@gmail.com>
@@ -8,7 +8,7 @@ License-File: LICENSE
8
8
  Keywords: activemodel,activerecord,orm,sqlalchemy,sqlmodel
9
9
  Requires-Python: >=3.12
10
10
  Requires-Dist: python-decouple-typed>=3.11.0
11
- Requires-Dist: sqlmodel>=0.0.27
11
+ Requires-Dist: sqlmodel==0.0.32
12
12
  Requires-Dist: textcase>=0.4.0
13
13
  Requires-Dist: typeid-python==0.3.3
14
14
  Description-Content-Type: text/markdown
@@ -13,7 +13,7 @@ activemodel/mixins/soft_delete.py,sha256=Ax4mGsQI7AVTE8c4GiWxpyB_W179-dDct79GtjP
13
13
  activemodel/mixins/timestamps.py,sha256=C6QQNnzrNUOW1EAsMpEVpImEeTIYDMPP0wocEw2RDQw,1078
14
14
  activemodel/mixins/typeid.py,sha256=777btWRUW6YBGPApeaEdHQaoKmwblehukHzmkKoXv6o,1340
15
15
  activemodel/patches/__init__.py,sha256=Jc6yYPtNCOBI6AdbKfeYUfLikpEdFyefM6h3nTLRID8,126
16
- activemodel/patches/get_column_from_field_patch.py,sha256=HRAljRDxWF03kA4wICWDO9KUKToVzESYp1tbKs-bg5A,4798
16
+ activemodel/patches/get_column_from_field_patch.py,sha256=30C9yMVTbhTcnRjk6HD_aklZCg2TGYkLASGSEe3NXtg,5026
17
17
  activemodel/pytest/__init__.py,sha256=IJpD-BwJuPii5IxTJoOCryaq4_oyXNRj4RjlS5Plmc8,112
18
18
  activemodel/pytest/factories.py,sha256=o9kBVCESZUD4ypTVfG2_FD2Zew3mAcnguVhagDH1Ry8,4016
19
19
  activemodel/pytest/plugin.py,sha256=IbRKTCjYnay0N5ucTK7PmA9ETx4OQOuR5hlFf3Lyez4,2681
@@ -24,8 +24,8 @@ activemodel/types/sqlalchemy_protocol.py,sha256=Uc8hKmTdx0boNQAthNYQNCbfxRwz0mGH
24
24
  activemodel/types/sqlalchemy_protocol.pyi,sha256=yhLXOiZtCHOLA6YNPu_-xSiUJhfi8dyfjcmcAFhDY-Y,5649
25
25
  activemodel/types/typeid.py,sha256=qycqklKv5nKuCqjJRnxA-6MjtcWJ4vFUsAVBc1ySwfg,7865
26
26
  activemodel/types/typeid_patch.py,sha256=Wkt8Ok_y49vEpuvhR8iB2xOcuFqa7vGC2RXYPcF6WZ0,670
27
- activemodel-0.14.1.dist-info/METADATA,sha256=EUnStn5l6Cm_uTEu5BJBl6M_o9ROsnPEq2ya_BebwI8,10750
28
- activemodel-0.14.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
29
- activemodel-0.14.1.dist-info/entry_points.txt,sha256=rytVrsNgUT4oDiW9RvRH6JBTHQn0hPZLK-jzQt3dY9s,51
30
- activemodel-0.14.1.dist-info/licenses/LICENSE,sha256=L8mmpX47rB-xtJ_HsK0zpfO6viEjxbLYGn70BMp8os4,1071
31
- activemodel-0.14.1.dist-info/RECORD,,
27
+ activemodel-0.15.0.dist-info/METADATA,sha256=NS3dJGENQw94myuKgm7Wt0kd-cRkztuMykLEf1cdOB8,10750
28
+ activemodel-0.15.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
29
+ activemodel-0.15.0.dist-info/entry_points.txt,sha256=rytVrsNgUT4oDiW9RvRH6JBTHQn0hPZLK-jzQt3dY9s,51
30
+ activemodel-0.15.0.dist-info/licenses/LICENSE,sha256=L8mmpX47rB-xtJ_HsK0zpfO6viEjxbLYGn70BMp8os4,1071
31
+ activemodel-0.15.0.dist-info/RECORD,,