Skip to content

Commit eaa5e15

Browse files
authored
feat!: declare models by overriding accessors, not by dunder (#17)
* feat!: declare models by overriding accessors, not by dunder Breaking, following rhosocial-activerecord: model fixtures and examples now override table_name(), primary_key(), pk_auto_generated(), read_only() and the locator methods instead of assigning __table_name__ and friends. The framework stopped reading those dunders, so a model still declaring them would fail with NotImplementedError at the first read. Produced by the core repository's declaration sweep (scripts/ d5_migrate_declarations.py), so every repository in the family carries the same shape. No new lint findings: the totals drop where the removed assignments took their imports with them. CI for this branch installs the family from the matching feature/declaration-surface ref, so a run exercises one revision across core, testsuite and the backend under test rather than a mixture of two. * ci: track the released core instead of the feature branch Workflow 'test.yml' installs this backend's dependencies from the other repositories in the family. Core's PR #140 is merged into release/v1.0.0.dev30, so the core ref now names that branch: a run of this repository tests the released core rather than a feature branch that no longer exists. The testsuite ref is unchanged and still names feature/declaration-surface: its migration has no merge yet, and pointing it at release/v1.0.0.dev17 would install fixtures that still declare the removed dunders. * ci: track the merged testsuite instead of the feature branch The testsuite's PR #32 is merged into release/v1.0.0.dev17, so the testsuite ref now names that branch. Every cross-repository install in a run therefore resolves to a released artifact: core from release/v1.0.0.dev30, the testsuite from release/v1.0.0.dev17, and this repository from its own feature branch.
1 parent 0aed4f5 commit eaa5e15

6 files changed

Lines changed: 312 additions & 44 deletions

File tree

‎.check_expression_baseline.json‎

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
{
2+
"entries": {
3+
"0278ac9b2d99f243": 2,
4+
"1182e6a5168fad4d": 2,
5+
"15d8c1ad5f05215a": 3,
6+
"2207e5f45a158db2": 1,
7+
"25138787f4f3c292": 1,
8+
"26f48745c86bcb6c": 3,
9+
"3a76dbbb69039561": 1,
10+
"481c9c33d29a2930": 1,
11+
"4a00de96e7c111a8": 1,
12+
"687f736f87568fa7": 1,
13+
"6881e297193f53fb": 2,
14+
"9cede0bc2031de72": 1,
15+
"a316d4185f6c5372": 1,
16+
"adbe0ad37f3fd6c9": 1,
17+
"aebaaac3f9ed8118": 1,
18+
"cc38ae350540075e": 1,
19+
"d55e960506f63189": 1,
20+
"df7098df4eaf8eba": 1,
21+
"e6738eb70915f158": 1,
22+
"e775979689c0aa90": 2,
23+
"ee65f2c95cb20172": 2,
24+
"f0868da2f55f9884": 1,
25+
"f27dd66925c1fb96": 1,
26+
"fabe6126b76a1058": 1,
27+
"fad924c61e4a2756": 1,
28+
"fc1ce8dd882c87df": 2
29+
},
30+
"findings": [
31+
{
32+
"found": "sparse: Optional[bool]",
33+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/expression/column.py",
34+
"rule": "ED-10.2"
35+
},
36+
{
37+
"found": "rowguidcol: Optional[bool]",
38+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/expression/column.py",
39+
"rule": "ED-10.2"
40+
},
41+
{
42+
"found": "sparse: Optional[bool]",
43+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/expression/column.py",
44+
"rule": "ED-10.2"
45+
},
46+
{
47+
"found": "rowguidcol: Optional[bool]",
48+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/expression/column.py",
49+
"rule": "ED-10.2"
50+
},
51+
{
52+
"found": "slots",
53+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/expression/objects.py",
54+
"rule": "ED-KWARGS"
55+
},
56+
{
57+
"found": "getattr(expr, \"cascade\", False)",
58+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/ddl_type.py",
59+
"rule": "ED-11.2"
60+
},
61+
{
62+
"found": "getattr(expr, \"restrict\", False)",
63+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/ddl_type.py",
64+
"rule": "ED-11.2"
65+
},
66+
{
67+
"found": "getattr(expr, 'definition_kind', type(expr).__name__)",
68+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/ddl_type.py",
69+
"rule": "ED-11.2"
70+
},
71+
{
72+
"found": "getattr(expr, 'definition_kind', type(expr).__name__)",
73+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/ddl_type.py",
74+
"rule": "ED-11.2"
75+
},
76+
{
77+
"found": "getattr(expr, 'action_kind', type(expr).__name__)",
78+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/ddl_type.py",
79+
"rule": "ED-11.2"
80+
},
81+
{
82+
"found": "getattr(expr.options, \"schemabinding\", False)",
83+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/ddl_view.py",
84+
"rule": "ED-11.2"
85+
},
86+
{
87+
"found": "getattr(clause, \"with_ties\", False)",
88+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/dql.py",
89+
"rule": "ED-11.2"
90+
},
91+
{
92+
"found": "getattr(expr, \"partition_scheme\", None)",
93+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/partition.py",
94+
"rule": "ED-11.2"
95+
},
96+
{
97+
"found": "getattr(expr, \"select_into_table\", None)",
98+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/protocol_support.py",
99+
"rule": "ED-11.2"
100+
},
101+
{
102+
"found": "getattr(expr, \"or_alter\", False)",
103+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
104+
"rule": "ED-11.2"
105+
},
106+
{
107+
"found": "getattr(expr, \"schema\", None)",
108+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
109+
"rule": "ED-11.2"
110+
},
111+
{
112+
"found": "getattr(expr, \"parameters\", None)",
113+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
114+
"rule": "ED-11.2"
115+
},
116+
{
117+
"found": "getattr(expr, \"body\", None)",
118+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
119+
"rule": "ED-11.2"
120+
},
121+
{
122+
"found": "getattr(expr, \"returns\", None)",
123+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
124+
"rule": "ED-11.2"
125+
},
126+
{
127+
"found": "getattr(expr, \"or_alter\", False)",
128+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
129+
"rule": "ED-11.2"
130+
},
131+
{
132+
"found": "getattr(expr, \"schema\", None)",
133+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
134+
"rule": "ED-11.2"
135+
},
136+
{
137+
"found": "getattr(expr, \"parameters\", None)",
138+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
139+
"rule": "ED-11.2"
140+
},
141+
{
142+
"found": "getattr(expr, \"body\", None)",
143+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
144+
"rule": "ED-11.2"
145+
},
146+
{
147+
"found": "getattr(expr, \"kind\", \"PROCEDURE\")",
148+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
149+
"rule": "ED-11.2"
150+
},
151+
{
152+
"found": "getattr(expr, \"if_exists\", False)",
153+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
154+
"rule": "ED-11.2"
155+
},
156+
{
157+
"found": "getattr(expr, \"schema\", None)",
158+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/routine.py",
159+
"rule": "ED-11.2"
160+
},
161+
{
162+
"found": "getattr(expr, \"table_name\", None)",
163+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
164+
"rule": "ED-11.2"
165+
},
166+
{
167+
"found": "getattr(expr, \"table\", None)",
168+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
169+
"rule": "ED-11.2"
170+
},
171+
{
172+
"found": "getattr(expr, \"timing\", \"AFTER\")",
173+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
174+
"rule": "ED-11.2"
175+
},
176+
{
177+
"found": "getattr(expr, \"events\", None)",
178+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
179+
"rule": "ED-11.2"
180+
},
181+
{
182+
"found": "getattr(expr, \"body\", None)",
183+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
184+
"rule": "ED-11.2"
185+
},
186+
{
187+
"found": "getattr(expr, \"or_alter\", False)",
188+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
189+
"rule": "ED-11.2"
190+
},
191+
{
192+
"found": "getattr(expr, \"schema\", None)",
193+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
194+
"rule": "ED-11.2"
195+
},
196+
{
197+
"found": "getattr(expr, \"schema\", None)",
198+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
199+
"rule": "ED-11.2"
200+
},
201+
{
202+
"found": "getattr(expr, \"if_exists\", False)",
203+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
204+
"rule": "ED-11.2"
205+
},
206+
{
207+
"found": "getattr(expr, \"schema\", None)",
208+
"path": "src/rhosocial/activerecord/backend/impl/sqlserver/mixins/trigger.py",
209+
"rule": "ED-11.2"
210+
}
211+
],
212+
"format": 1
213+
}

‎.github/workflows/test.yml‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ jobs:
5454
5555
- name: Install activerecord and testsuite from PyPI
5656
run: |
57-
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@feature/error-taxonomy" # NOSONAR
58-
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@feature/error-taxonomy" # NOSONAR
57+
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev30" # NOSONAR
58+
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev17" # NOSONAR
5959
6060
- name: Install dependencies
6161
run: |
@@ -144,8 +144,8 @@ jobs:
144144
145145
- name: Install activerecord and testsuite from PyPI
146146
run: |
147-
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@feature/error-taxonomy" # NOSONAR
148-
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@feature/error-taxonomy" # NOSONAR
147+
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev30" # NOSONAR
148+
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev17" # NOSONAR
149149
150150
- name: Install dependencies
151151
run: |
@@ -234,8 +234,8 @@ jobs:
234234
235235
- name: Install activerecord and testsuite from PyPI
236236
run: |
237-
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@feature/error-taxonomy" # NOSONAR
238-
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@feature/error-taxonomy" # NOSONAR
237+
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev30" # NOSONAR
238+
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev17" # NOSONAR
239239
240240
- name: Install dependencies
241241
run: |
@@ -324,8 +324,8 @@ jobs:
324324
325325
- name: Install activerecord and testsuite from PyPI
326326
run: |
327-
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@feature/error-taxonomy" # NOSONAR
328-
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@feature/error-taxonomy" # NOSONAR
327+
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev30" # NOSONAR
328+
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev17" # NOSONAR
329329
330330
- name: Install dependencies
331331
run: |
@@ -414,8 +414,8 @@ jobs:
414414
415415
- name: Install activerecord and testsuite from PyPI
416416
run: |
417-
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@feature/error-taxonomy" # NOSONAR
418-
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@feature/error-taxonomy" # NOSONAR
417+
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev30" # NOSONAR
418+
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev17" # NOSONAR
419419
420420
- name: Install dependencies
421421
run: |
@@ -504,8 +504,8 @@ jobs:
504504
505505
- name: Install activerecord and testsuite from PyPI
506506
run: |
507-
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@feature/error-taxonomy" # NOSONAR
508-
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@feature/error-taxonomy" # NOSONAR
507+
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev30" # NOSONAR
508+
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev17" # NOSONAR
509509
510510
- name: Install dependencies
511511
run: |
@@ -595,8 +595,8 @@ jobs:
595595
596596
- name: Install activerecord and testsuite from PyPI
597597
run: |
598-
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@feature/error-taxonomy" # NOSONAR
599-
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@feature/error-taxonomy" # NOSONAR
598+
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev30" # NOSONAR
599+
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev17" # NOSONAR
600600
601601
- name: Install dependencies
602602
run: |
@@ -685,8 +685,8 @@ jobs:
685685
686686
- name: Install activerecord and testsuite from PyPI
687687
run: |
688-
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@feature/error-taxonomy" # NOSONAR
689-
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@feature/error-taxonomy" # NOSONAR
688+
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev30" # NOSONAR
689+
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev17" # NOSONAR
690690
691691
- name: Install dependencies
692692
run: |
@@ -784,8 +784,8 @@ jobs:
784784
785785
- name: Install activerecord and testsuite from PyPI
786786
run: |
787-
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@feature/error-taxonomy" # NOSONAR
788-
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@feature/error-taxonomy" # NOSONAR
787+
pip install "rhosocial-activerecord @ git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev30" # NOSONAR
788+
pip install "rhosocial-activerecord-testsuite @ git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev17" # NOSONAR
789789
790790
- name: Install dependencies
791791
run: |

‎tests/providers/basic_connection.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from rhosocial.activerecord.model import ActiveRecord, AsyncActiveRecord
1111
from rhosocial.activerecord.backend.impl.sqlserver.backend import SQLServerBackend
12-
from rhosocial.activerecord.backend.impl.sqlserver.config import SQLServerConnectionConfig
1312
from rhosocial.activerecord.connection.pool import BackendPool, AsyncBackendPool, PoolConfig
1413
from rhosocial.activerecord.backend.options import ExecutionOptions
1514
from rhosocial.activerecord.backend.schema import StatementType
@@ -20,15 +19,21 @@
2019

2120
class SyncTestUser(ActiveRecord):
2221
"""Sync test user model for connection pool tests."""
23-
__table_name__ = "test_users"
22+
@classmethod
23+
def table_name(cls):
24+
return "test_users"
25+
2426
id: Optional[int] = None
2527
name: str
2628
email: str
2729

2830

2931
class AsyncTestUser(AsyncActiveRecord):
3032
"""Async test user model for connection pool tests."""
31-
__table_name__ = "test_users"
33+
@classmethod
34+
def table_name(cls):
35+
return "test_users"
36+
3237
id: Optional[int] = None
3338
name: str
3439
email: str

‎tests/providers/query_connection.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from rhosocial.activerecord.model import ActiveRecord, AsyncActiveRecord
1111
from rhosocial.activerecord.backend.impl.sqlserver.backend import SQLServerBackend
12-
from rhosocial.activerecord.backend.impl.sqlserver.config import SQLServerConnectionConfig
1312
from rhosocial.activerecord.connection.pool import BackendPool, AsyncBackendPool, PoolConfig
1413
from rhosocial.activerecord.backend.options import ExecutionOptions
1514
from rhosocial.activerecord.backend.schema import StatementType
@@ -20,15 +19,21 @@
2019

2120
class SyncQueryTestUser(ActiveRecord):
2221
"""Sync test user model for query connection pool tests."""
23-
__table_name__ = "test_users"
22+
@classmethod
23+
def table_name(cls):
24+
return "test_users"
25+
2426
id: Optional[int] = None
2527
name: str
2628
email: str
2729

2830

2931
class AsyncQueryTestUser(AsyncActiveRecord):
3032
"""Async test user model for query connection pool tests."""
31-
__table_name__ = "test_users"
33+
@classmethod
34+
def table_name(cls):
35+
return "test_users"
36+
3237
id: Optional[int] = None
3338
name: str
3439
email: str

0 commit comments

Comments
 (0)