storepy 5.3.1__tar.gz → 5.3.2__tar.gz
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.
- {storepy-5.3.1/src/storepy.egg-info → storepy-5.3.2}/PKG-INFO +47 -1
- {storepy-5.3.1 → storepy-5.3.2}/README.md +46 -0
- {storepy-5.3.1 → storepy-5.3.2}/pyproject.toml +1 -1
- {storepy-5.3.1 → storepy-5.3.2/src/storepy.egg-info}/PKG-INFO +47 -1
- {storepy-5.3.1 → storepy-5.3.2}/LICENSE +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/setup.cfg +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/adapters/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/adapters/http.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/ask.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/ask_knowledge.md +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/bootstrap.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/cache/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/cache/context.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/cache/provider.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/cache/redis_io.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/capabilities.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/core.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/crud/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/crud/claim.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/crud/exec.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/crud/id.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/crud/mutation.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/crud/query.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/crud/triggers.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/crud/write.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/datasource.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/ddl.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/degraded.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/executors/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/executors/_values.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/executors/mongo.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/executors/mysql.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/executors/postgres.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/executors/sqlite.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/feedback.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/introspect/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/introspect/mysql.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/introspect/postgres.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/introspect/sqlite.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/llm.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/load.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/local/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/local/handle.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/local/store.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/memory/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/metadef.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/migrate.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/naming.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/permission.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/reindex.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/resource/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/resource/providers/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/resource/providers/local.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/resource/providers/s3.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/scheduler/__init__.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/schema.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/scope.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/secure.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/sync.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/vector_index.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/vector_scan.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/py_store/workflow.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/storepy.egg-info/SOURCES.txt +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/storepy.egg-info/dependency_links.txt +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/storepy.egg-info/requires.txt +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/src/storepy.egg-info/top_level.txt +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_access_keys.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_adapters.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_ask.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_cache.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_cache_link.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_claim_concurrency.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_compute_override.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_coverage_margin.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_federation_e2e.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_feedback_flush.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_field_name_type.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_fns_binding.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_host_contract.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_host_paths.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_inline_agg.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_load.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_local_store.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_memory.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_metadef.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_migrate.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_migration.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_mongo_executor.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_mongo_session.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_multi_datasource.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_parity_deny.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_parity_local.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_parity_local_memory.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_parity_scope.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_policy_isolation.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_profile.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_py_store.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_raw_sql_and_ddl.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_rbac_host.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_real_backends_e2e.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_require_context.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_resource.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_resource_e2e.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_resource_pools.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_resource_units.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_scenario_course_platform.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_scenario_manager_transaction.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_scheduler.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_session.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_sql_commit_and_registry.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_triggers.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_vector_conformance.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_vector_index.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_vector_scan.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_vector_units.py +0 -0
- {storepy-5.3.1 → storepy-5.3.2}/tests/test_workflow.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: storepy
|
|
3
|
-
Version: 5.3.
|
|
3
|
+
Version: 5.3.2
|
|
4
4
|
Summary: Multi-backend data layer for Python asyncio (MongoDB, MySQL, SQLite, PostgreSQL, local disk): pure JSON schemas, GQL tree queries compiled to a single native query, GROUP BY/HAVING aggregation, computed columns, soft-delete and role-based access control
|
|
5
5
|
Author-email: 丁滔 <coen_ddt@qq.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -195,6 +195,52 @@ python example/course-platform/impl/harness.py --backend sqlite --out .out/sqlit
|
|
|
195
195
|
|
|
196
196
|
An unreachable backend is reported as `available: false` with a `skip_reason` — it is never silently counted as a pass. The behaviour matrix is the test suite: `test_parity_local.py`, `test_parity_deny.py`, `test_require_context.py`, `test_scenario_course_platform.py` and `test_real_backends_e2e.py` each pin one slice of it.
|
|
197
197
|
|
|
198
|
+
## Normative excerpts
|
|
199
|
+
|
|
200
|
+
Three contracts are normative — directory-to-location resolution, naming translation, and `fnRef` binding. They are reproduced verbatim here and checked against every carrier in CI (`scripts/check-spec-snippets.js`).
|
|
201
|
+
|
|
202
|
+
<!-- SPEC:LOCATION:BEGIN -->
|
|
203
|
+
### Location: directory semantics + connection config (definitions carry no location)
|
|
204
|
+
|
|
205
|
+
A schema definition file contains no location fields (no `source` / `database` / `schema`; `namespace` is removed). Location is resolved from the definition directory layout plus the connection config:
|
|
206
|
+
|
|
207
|
+
- Under the definitions root `<defs-root>/`: the first directory level is the `database`; PostgreSQL adds a second level for `schema` (Mongo / MySQL / SQLite have no such level); deeper levels are free-form and flattened at load time (no hierarchy semantics).
|
|
208
|
+
- The connection config (`store.config.json`) declares `sources` (`kind` + `databases`) and `defs`; `kind` decides whether that database directory is read one level deeper for `schema`.
|
|
209
|
+
- Location fields are `source` / `database` / `schema` (PG only) / `collection`; the word `namespace` is removed.
|
|
210
|
+
- Same-named schemas: exactly one primary (no `replica`); the rest declare `{ "name": "...", "replica": true }`, add only a link, and must not repeat the structure. Zero or two-or-more primaries is an error.
|
|
211
|
+
- A duplicated `name` within one load batch is an error and the service does not start; re-loading the same `name` across versions bumps its version by 1.
|
|
212
|
+
- Writes are synchronized within a single connection, across the primary plus all links, in one transaction; a write spanning a cross-connection link is explicitly rejected or degraded with a feedback event (never silent).
|
|
213
|
+
<!-- SPEC:LOCATION:END -->
|
|
214
|
+
|
|
215
|
+
<!-- SPEC:NAMING-STYLE:BEGIN -->
|
|
216
|
+
### Naming: freeform definitions, system-directed translation
|
|
217
|
+
|
|
218
|
+
Definitions (`collection`, fields, referenced relation fields, computed-column keys, `fnRef` values, index names) may use any style; the engine translates them to the target style. Contract keys (`fnRef`, `localField`, `foreignField`, `asyncFn`, `type`, ...) and the schema `name` are never translated.
|
|
219
|
+
|
|
220
|
+
| Target | Style | Example (`orderTotal`) |
|
|
221
|
+
|---|---|---|
|
|
222
|
+
| MySQL / PostgreSQL / SQLite (physical) | snake_case | `order_total` |
|
|
223
|
+
| MongoDB (physical) | camelCase | `orderTotal` |
|
|
224
|
+
| Node.js / Java / C# / Rust (code; computed columns follow) | camelCase | `orderTotal` |
|
|
225
|
+
| Go (code; computed columns follow) | PascalCase (must be exported) | `OrderTotal` |
|
|
226
|
+
| Python (code; computed columns follow) | snake_case | `order_total` |
|
|
227
|
+
|
|
228
|
+
Canonicalization (single implementation `core::naming`, re-exported by the bindings; hosts must not re-implement it): split on `_`, `-`, `.`, space and at lower/digit-to-upper boundaries; a trailing uppercase in a run followed by a lowercase starts the next token (`HTTPServer` -> `[http, server]`, `userID` -> `[user, id]`); digits stay inside a token (`order2Items` -> `[order2, items]`). Reassembly: snake = `t1_t2`, camel = `t1T2`, pascal = `T1T2`.
|
|
229
|
+
|
|
230
|
+
Two logical names in one schema that canonicalize equal (`orderTotal` vs `order_total`) is an error `ERR_NAME_CONFLICT:` and the service does not start (never silently overwritten). The `fields` key space is fully open — no field name is reserved: contract keys (`type`, `default`, ...) live inside a field's definition object at a different level, so `fields: { type: { type: "string" } }` is valid. Literal reserved names are only `_id` (framework primary key) and `_score` (vector score column).
|
|
231
|
+
<!-- SPEC:NAMING-STYLE:END -->
|
|
232
|
+
|
|
233
|
+
<!-- SPEC:FNREF:BEGIN -->
|
|
234
|
+
### Computed columns: `fnRef` binding by composite name + canonical match
|
|
235
|
+
|
|
236
|
+
Computed columns live at the schema top level, `computes: { <key>: { type, fn | asyncFn | agg, fnRef?, depends?, read? } }` (`fn` / `asyncFn` / `agg` are mutually exclusive).
|
|
237
|
+
|
|
238
|
+
- The logical `fnRef` defaults to `<schema.name>.<computed-column key>` (generated, never hand-written); since `name` is globally unique, the `fnRef` is globally unique too.
|
|
239
|
+
- Host implementations bind by canonicalization: both the implementation's name in the host language style and the schema's logical `fnRef` are canonicalized to token sequences and compared. So Node's `orderAmountLabel` and Python's `order_amount_label` bind to the same logical computed column.
|
|
240
|
+
- Reusing one implementation across schemas: write an explicit shared name (e.g. `"fnRef": "common.moneyLabel"`); naming goes from required to optional.
|
|
241
|
+
- Every declared `fnRef` must have an implementation, otherwise the service fails to start with `ERR_FN_MISSING`.
|
|
242
|
+
<!-- SPEC:FNREF:END -->
|
|
243
|
+
|
|
198
244
|
## Boundaries: when not to use it
|
|
199
245
|
|
|
200
246
|
- **You want an ORM with model classes and a migration engine.** py-store models are runtime dicts, chosen so the same definition runs in Python and Node.js. `generate_ddl()` renders `CREATE TABLE` text and `migrate()` orchestrates a whitelist of changes (add table / column / index, widen types); neither replaces Alembic or Django migrations.
|
|
@@ -153,6 +153,52 @@ python example/course-platform/impl/harness.py --backend sqlite --out .out/sqlit
|
|
|
153
153
|
|
|
154
154
|
An unreachable backend is reported as `available: false` with a `skip_reason` — it is never silently counted as a pass. The behaviour matrix is the test suite: `test_parity_local.py`, `test_parity_deny.py`, `test_require_context.py`, `test_scenario_course_platform.py` and `test_real_backends_e2e.py` each pin one slice of it.
|
|
155
155
|
|
|
156
|
+
## Normative excerpts
|
|
157
|
+
|
|
158
|
+
Three contracts are normative — directory-to-location resolution, naming translation, and `fnRef` binding. They are reproduced verbatim here and checked against every carrier in CI (`scripts/check-spec-snippets.js`).
|
|
159
|
+
|
|
160
|
+
<!-- SPEC:LOCATION:BEGIN -->
|
|
161
|
+
### Location: directory semantics + connection config (definitions carry no location)
|
|
162
|
+
|
|
163
|
+
A schema definition file contains no location fields (no `source` / `database` / `schema`; `namespace` is removed). Location is resolved from the definition directory layout plus the connection config:
|
|
164
|
+
|
|
165
|
+
- Under the definitions root `<defs-root>/`: the first directory level is the `database`; PostgreSQL adds a second level for `schema` (Mongo / MySQL / SQLite have no such level); deeper levels are free-form and flattened at load time (no hierarchy semantics).
|
|
166
|
+
- The connection config (`store.config.json`) declares `sources` (`kind` + `databases`) and `defs`; `kind` decides whether that database directory is read one level deeper for `schema`.
|
|
167
|
+
- Location fields are `source` / `database` / `schema` (PG only) / `collection`; the word `namespace` is removed.
|
|
168
|
+
- Same-named schemas: exactly one primary (no `replica`); the rest declare `{ "name": "...", "replica": true }`, add only a link, and must not repeat the structure. Zero or two-or-more primaries is an error.
|
|
169
|
+
- A duplicated `name` within one load batch is an error and the service does not start; re-loading the same `name` across versions bumps its version by 1.
|
|
170
|
+
- Writes are synchronized within a single connection, across the primary plus all links, in one transaction; a write spanning a cross-connection link is explicitly rejected or degraded with a feedback event (never silent).
|
|
171
|
+
<!-- SPEC:LOCATION:END -->
|
|
172
|
+
|
|
173
|
+
<!-- SPEC:NAMING-STYLE:BEGIN -->
|
|
174
|
+
### Naming: freeform definitions, system-directed translation
|
|
175
|
+
|
|
176
|
+
Definitions (`collection`, fields, referenced relation fields, computed-column keys, `fnRef` values, index names) may use any style; the engine translates them to the target style. Contract keys (`fnRef`, `localField`, `foreignField`, `asyncFn`, `type`, ...) and the schema `name` are never translated.
|
|
177
|
+
|
|
178
|
+
| Target | Style | Example (`orderTotal`) |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| MySQL / PostgreSQL / SQLite (physical) | snake_case | `order_total` |
|
|
181
|
+
| MongoDB (physical) | camelCase | `orderTotal` |
|
|
182
|
+
| Node.js / Java / C# / Rust (code; computed columns follow) | camelCase | `orderTotal` |
|
|
183
|
+
| Go (code; computed columns follow) | PascalCase (must be exported) | `OrderTotal` |
|
|
184
|
+
| Python (code; computed columns follow) | snake_case | `order_total` |
|
|
185
|
+
|
|
186
|
+
Canonicalization (single implementation `core::naming`, re-exported by the bindings; hosts must not re-implement it): split on `_`, `-`, `.`, space and at lower/digit-to-upper boundaries; a trailing uppercase in a run followed by a lowercase starts the next token (`HTTPServer` -> `[http, server]`, `userID` -> `[user, id]`); digits stay inside a token (`order2Items` -> `[order2, items]`). Reassembly: snake = `t1_t2`, camel = `t1T2`, pascal = `T1T2`.
|
|
187
|
+
|
|
188
|
+
Two logical names in one schema that canonicalize equal (`orderTotal` vs `order_total`) is an error `ERR_NAME_CONFLICT:` and the service does not start (never silently overwritten). The `fields` key space is fully open — no field name is reserved: contract keys (`type`, `default`, ...) live inside a field's definition object at a different level, so `fields: { type: { type: "string" } }` is valid. Literal reserved names are only `_id` (framework primary key) and `_score` (vector score column).
|
|
189
|
+
<!-- SPEC:NAMING-STYLE:END -->
|
|
190
|
+
|
|
191
|
+
<!-- SPEC:FNREF:BEGIN -->
|
|
192
|
+
### Computed columns: `fnRef` binding by composite name + canonical match
|
|
193
|
+
|
|
194
|
+
Computed columns live at the schema top level, `computes: { <key>: { type, fn | asyncFn | agg, fnRef?, depends?, read? } }` (`fn` / `asyncFn` / `agg` are mutually exclusive).
|
|
195
|
+
|
|
196
|
+
- The logical `fnRef` defaults to `<schema.name>.<computed-column key>` (generated, never hand-written); since `name` is globally unique, the `fnRef` is globally unique too.
|
|
197
|
+
- Host implementations bind by canonicalization: both the implementation's name in the host language style and the schema's logical `fnRef` are canonicalized to token sequences and compared. So Node's `orderAmountLabel` and Python's `order_amount_label` bind to the same logical computed column.
|
|
198
|
+
- Reusing one implementation across schemas: write an explicit shared name (e.g. `"fnRef": "common.moneyLabel"`); naming goes from required to optional.
|
|
199
|
+
- Every declared `fnRef` must have an implementation, otherwise the service fails to start with `ERR_FN_MISSING`.
|
|
200
|
+
<!-- SPEC:FNREF:END -->
|
|
201
|
+
|
|
156
202
|
## Boundaries: when not to use it
|
|
157
203
|
|
|
158
204
|
- **You want an ORM with model classes and a migration engine.** py-store models are runtime dicts, chosen so the same definition runs in Python and Node.js. `generate_ddl()` renders `CREATE TABLE` text and `migrate()` orchestrates a whitelist of changes (add table / column / index, widen types); neither replaces Alembic or Django migrations.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "storepy"
|
|
7
|
-
version = "5.3.
|
|
7
|
+
version = "5.3.2"
|
|
8
8
|
description = "Multi-backend data layer for Python asyncio (MongoDB, MySQL, SQLite, PostgreSQL, local disk): pure JSON schemas, GQL tree queries compiled to a single native query, GROUP BY/HAVING aggregation, computed columns, soft-delete and role-based access control"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: storepy
|
|
3
|
-
Version: 5.3.
|
|
3
|
+
Version: 5.3.2
|
|
4
4
|
Summary: Multi-backend data layer for Python asyncio (MongoDB, MySQL, SQLite, PostgreSQL, local disk): pure JSON schemas, GQL tree queries compiled to a single native query, GROUP BY/HAVING aggregation, computed columns, soft-delete and role-based access control
|
|
5
5
|
Author-email: 丁滔 <coen_ddt@qq.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -195,6 +195,52 @@ python example/course-platform/impl/harness.py --backend sqlite --out .out/sqlit
|
|
|
195
195
|
|
|
196
196
|
An unreachable backend is reported as `available: false` with a `skip_reason` — it is never silently counted as a pass. The behaviour matrix is the test suite: `test_parity_local.py`, `test_parity_deny.py`, `test_require_context.py`, `test_scenario_course_platform.py` and `test_real_backends_e2e.py` each pin one slice of it.
|
|
197
197
|
|
|
198
|
+
## Normative excerpts
|
|
199
|
+
|
|
200
|
+
Three contracts are normative — directory-to-location resolution, naming translation, and `fnRef` binding. They are reproduced verbatim here and checked against every carrier in CI (`scripts/check-spec-snippets.js`).
|
|
201
|
+
|
|
202
|
+
<!-- SPEC:LOCATION:BEGIN -->
|
|
203
|
+
### Location: directory semantics + connection config (definitions carry no location)
|
|
204
|
+
|
|
205
|
+
A schema definition file contains no location fields (no `source` / `database` / `schema`; `namespace` is removed). Location is resolved from the definition directory layout plus the connection config:
|
|
206
|
+
|
|
207
|
+
- Under the definitions root `<defs-root>/`: the first directory level is the `database`; PostgreSQL adds a second level for `schema` (Mongo / MySQL / SQLite have no such level); deeper levels are free-form and flattened at load time (no hierarchy semantics).
|
|
208
|
+
- The connection config (`store.config.json`) declares `sources` (`kind` + `databases`) and `defs`; `kind` decides whether that database directory is read one level deeper for `schema`.
|
|
209
|
+
- Location fields are `source` / `database` / `schema` (PG only) / `collection`; the word `namespace` is removed.
|
|
210
|
+
- Same-named schemas: exactly one primary (no `replica`); the rest declare `{ "name": "...", "replica": true }`, add only a link, and must not repeat the structure. Zero or two-or-more primaries is an error.
|
|
211
|
+
- A duplicated `name` within one load batch is an error and the service does not start; re-loading the same `name` across versions bumps its version by 1.
|
|
212
|
+
- Writes are synchronized within a single connection, across the primary plus all links, in one transaction; a write spanning a cross-connection link is explicitly rejected or degraded with a feedback event (never silent).
|
|
213
|
+
<!-- SPEC:LOCATION:END -->
|
|
214
|
+
|
|
215
|
+
<!-- SPEC:NAMING-STYLE:BEGIN -->
|
|
216
|
+
### Naming: freeform definitions, system-directed translation
|
|
217
|
+
|
|
218
|
+
Definitions (`collection`, fields, referenced relation fields, computed-column keys, `fnRef` values, index names) may use any style; the engine translates them to the target style. Contract keys (`fnRef`, `localField`, `foreignField`, `asyncFn`, `type`, ...) and the schema `name` are never translated.
|
|
219
|
+
|
|
220
|
+
| Target | Style | Example (`orderTotal`) |
|
|
221
|
+
|---|---|---|
|
|
222
|
+
| MySQL / PostgreSQL / SQLite (physical) | snake_case | `order_total` |
|
|
223
|
+
| MongoDB (physical) | camelCase | `orderTotal` |
|
|
224
|
+
| Node.js / Java / C# / Rust (code; computed columns follow) | camelCase | `orderTotal` |
|
|
225
|
+
| Go (code; computed columns follow) | PascalCase (must be exported) | `OrderTotal` |
|
|
226
|
+
| Python (code; computed columns follow) | snake_case | `order_total` |
|
|
227
|
+
|
|
228
|
+
Canonicalization (single implementation `core::naming`, re-exported by the bindings; hosts must not re-implement it): split on `_`, `-`, `.`, space and at lower/digit-to-upper boundaries; a trailing uppercase in a run followed by a lowercase starts the next token (`HTTPServer` -> `[http, server]`, `userID` -> `[user, id]`); digits stay inside a token (`order2Items` -> `[order2, items]`). Reassembly: snake = `t1_t2`, camel = `t1T2`, pascal = `T1T2`.
|
|
229
|
+
|
|
230
|
+
Two logical names in one schema that canonicalize equal (`orderTotal` vs `order_total`) is an error `ERR_NAME_CONFLICT:` and the service does not start (never silently overwritten). The `fields` key space is fully open — no field name is reserved: contract keys (`type`, `default`, ...) live inside a field's definition object at a different level, so `fields: { type: { type: "string" } }` is valid. Literal reserved names are only `_id` (framework primary key) and `_score` (vector score column).
|
|
231
|
+
<!-- SPEC:NAMING-STYLE:END -->
|
|
232
|
+
|
|
233
|
+
<!-- SPEC:FNREF:BEGIN -->
|
|
234
|
+
### Computed columns: `fnRef` binding by composite name + canonical match
|
|
235
|
+
|
|
236
|
+
Computed columns live at the schema top level, `computes: { <key>: { type, fn | asyncFn | agg, fnRef?, depends?, read? } }` (`fn` / `asyncFn` / `agg` are mutually exclusive).
|
|
237
|
+
|
|
238
|
+
- The logical `fnRef` defaults to `<schema.name>.<computed-column key>` (generated, never hand-written); since `name` is globally unique, the `fnRef` is globally unique too.
|
|
239
|
+
- Host implementations bind by canonicalization: both the implementation's name in the host language style and the schema's logical `fnRef` are canonicalized to token sequences and compared. So Node's `orderAmountLabel` and Python's `order_amount_label` bind to the same logical computed column.
|
|
240
|
+
- Reusing one implementation across schemas: write an explicit shared name (e.g. `"fnRef": "common.moneyLabel"`); naming goes from required to optional.
|
|
241
|
+
- Every declared `fnRef` must have an implementation, otherwise the service fails to start with `ERR_FN_MISSING`.
|
|
242
|
+
<!-- SPEC:FNREF:END -->
|
|
243
|
+
|
|
198
244
|
## Boundaries: when not to use it
|
|
199
245
|
|
|
200
246
|
- **You want an ORM with model classes and a migration engine.** py-store models are runtime dicts, chosen so the same definition runs in Python and Node.js. `generate_ddl()` renders `CREATE TABLE` text and `migrate()` orchestrates a whitelist of changes (add table / column / index, widen types); neither replaces Alembic or Django migrations.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|