surreal-orm-lite 0.37.1__tar.gz → 0.37.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.
Files changed (51) hide show
  1. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/CHANGELOG.md +24 -0
  2. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/PKG-INFO +11 -7
  3. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/README.md +10 -6
  4. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/pyproject.toml +1 -1
  5. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/__init__.py +1 -1
  6. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/define_parser.py +4 -2
  7. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/model_auth.py +33 -12
  8. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/schema_state.py +3 -2
  9. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/.gitignore +0 -0
  10. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/LICENSE +0 -0
  11. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/Makefile +0 -0
  12. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/_sdk.py +0 -0
  13. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/aggregations.py +0 -0
  14. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/auth.py +0 -0
  15. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/cache.py +0 -0
  16. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/changefeed.py +0 -0
  17. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/concurrency.py +0 -0
  18. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/connection_config.py +0 -0
  19. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/connection_manager.py +0 -0
  20. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/constants.py +0 -0
  21. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/decoding.py +0 -0
  22. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/edge.py +0 -0
  23. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/embedded.py +0 -0
  24. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/encoding.py +0 -0
  25. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/enum.py +0 -0
  26. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/exceptions.py +0 -0
  27. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/functions.py +0 -0
  28. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/geo.py +0 -0
  29. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/hybrid.py +0 -0
  30. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/introspection.py +0 -0
  31. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/live.py +0 -0
  32. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/model_base.py +0 -0
  33. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/model_ddl.py +0 -0
  34. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/model_generator.py +0 -0
  35. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/py.typed +0 -0
  36. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/q.py +0 -0
  37. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/query_set.py +0 -0
  38. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/routing.py +0 -0
  39. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/schema.py +0 -0
  40. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/search.py +0 -0
  41. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/signals.py +0 -0
  42. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/subquery.py +0 -0
  43. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/surql_literal.py +0 -0
  44. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/testing/__init__.py +0 -0
  45. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/testing/database.py +0 -0
  46. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/testing/fixtures.py +0 -0
  47. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/time_travel.py +0 -0
  48. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/transaction.py +0 -0
  49. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/types.py +0 -0
  50. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/utils.py +0 -0
  51. {surreal_orm_lite-0.37.1 → surreal_orm_lite-0.37.2}/src/surreal_orm_lite/vector.py +0 -0
@@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.37.2] - 2026-10-27
9
+
10
+ A model with a `primary_key` can have its access defined on SurrealDB 3.x. No new public API.
11
+
12
+ ### Fixed
13
+
14
+ - **`access_ddl()` and `define_access()` work for a model with a `primary_key` on SurrealDB 3.x** (#338).
15
+ The SIGNUP clause built the record id with `type::thing('<table>', $<key>)`, which 3.x refuses at
16
+ `DEFINE`, so `define_access()` failed there; `type::record(table, key)` is no replacement, since 2.x
17
+ reads it as a type check that fails every signup. SIGNUP now sets the id from the bound key,
18
+ `CREATE <table> SET id = $<key>, ...`, a statement accepted by 3.x, 2.x and the embedded engine
19
+ that gives the record id `<table>:<key>` on all of them. `access_ddl()` stays pure, with no
20
+ version parameter, and a model without a `primary_key` is unchanged.
21
+ - **A signup leaving the `primary_key` as `None` is refused before the exchange.** `SET id = NONE`
22
+ would have the server mint a random record id, one no `objects().get(<key>)` addresses; the
23
+ `ValueError` names the key.
24
+ - **`parse_define_access()` reads the new form**: the `id = $<key>` item is one of `signup_fields`.
25
+ The older `type::thing(...)` and `type::record(...)` targets are still read.
26
+
27
+ ### Notes
28
+
29
+ - **Upgrading**: re-run `define_access()` for such a model to replace the old SIGNUP clause. Accesses
30
+ already defined on 2.x keep working; on 2.x the old clause and the new one create the same records.
31
+
8
32
  ## [0.37.1] - 2026-10-24
9
33
 
10
34
  Follow-ups to the review of v0.36.3 (#327): a `Literal[None]` member of a vector field's union
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: surreal-orm-lite
3
- Version: 0.37.1
3
+ Version: 0.37.2
4
4
  Summary: Lightweight Django-style ORM for SurrealDB using the official Python SDK. Async support with Pydantic validation.
5
5
  Project-URL: Homepage, https://github.com/EulogySnowfall/SurrealDB-ORM-lite
6
6
  Project-URL: Documentation, https://github.com/EulogySnowfall/SurrealDB-ORM-lite
@@ -1297,7 +1297,9 @@ a concurrent server).
1297
1297
 
1298
1298
  The model must declare either an `id` field or a `primary_key`, as every ORM model must. Prefer
1299
1299
  `id` here so the server mints the record id during SIGNUP; configure `primary_key` when identity
1300
- _is_ a column, and the SIGNUP clause targets `type::thing(…)` to match.
1300
+ _is_ a column, and the SIGNUP clause sets the record id from it to match
1301
+ (`CREATE User SET id = $email, email = $email, …`): the same statement on SurrealDB 2.x, 3.x and the embedded engine,
1302
+ and the record id is the key on all of them.
1301
1303
 
1302
1304
  #### Configuration
1303
1305
 
@@ -4505,10 +4507,11 @@ reads, stores, logs or writes them.
4505
4507
  for a field without `TYPE`, as in the full ORM.
4506
4508
  - **Accesses are database-level**: they are in `schema.accesses`, and `TableState` has no `access` attribute; find
4507
4509
  a table's with `[a for a in schema.accesses.values() if a.table == "user"]`. `table`, `signup_fields` and
4508
- `signin_where` are read from `SIGNUP (CREATE <table> SET …)` (also `CREATE type::thing('<table>', …) SET …` and
4509
- `CREATE type::record('<table>', …) SET …`, the forms `define_access()` uses for a `primary_key`) and
4510
- `SIGNIN (SELECT … FROM <table> WHERE …)`. The full ORM reads the first form only, and another shape leaves them
4511
- empty, with field names unescaped; durations are kept as rendered, `'NONE'` included.
4510
+ `signin_where` are read from `SIGNUP (CREATE <table> SET …)` (the form `define_access()` uses, whose
4511
+ `id = $<key>` for a `primary_key` is one of the `signup_fields`; also `CREATE type::thing('<table>', …) SET …` and
4512
+ `CREATE type::record('<table>', …) SET …`) and `SIGNIN (SELECT … FROM <table> WHERE …)`. The full ORM reads the
4513
+ first form only, and another shape leaves them empty, with field names unescaped; durations are kept as rendered,
4514
+ `'NONE'` included.
4512
4515
  - **`encrypted` is not provided**: the lite has no `Encrypted` type, so a hashing `VALUE`
4513
4516
  (`crypto::argon2::generate($value)`) stays in `FieldState.value` and the field is generated as a writable field.
4514
4517
  - **APIs and the GraphQL config are not typed**: their definitions are in `SchemaState.other["apis"]` and
@@ -6821,7 +6824,7 @@ features introduced in SurrealDB 3.x. On 2.x the ORM degrades gracefully. Capabi
6821
6824
  listed behave the same on both lines. The 2.x column was measured on 2.6.5 and holds unchanged
6822
6825
  on 2.7.0. The 3.x column was measured on 3.2.4 and holds on 3.3.0, except where a row says
6823
6826
  otherwise. The full suite and every divergence below were re-verified on both new versions.
6824
- Rows added in v0.20.0 were measured directly on 2.7.0 and 3.3.0; rows added in v0.21.0 on 2.7.0 and 3.3.2, re-verified on 3.3.3, with 3.1.5 where it differs; rows added in v0.22.0 on 2.7.0 and 3.3.3, with 3.1.5 where it differs; rows added in v0.23.0 on 2.7.0 and 3.3.4, with 3.1.5 where it differs; rows added in v0.24.0 on 2.7.0 and 3.3.4, identical on 3.1.5; rows added in v0.26.0 on 2.7.0 and 3.3.4, in memory and on versioned storage, identical on 3.1.5; rows added in v0.27.0 on 2.7.0 and 3.3.4, with 3.1.5 where it differs; rows added in v0.28.0 on 2.7.0 and 3.3.4, identical on 3.1.5; the rows added in v0.28.1 on 2.7.0 and 3.3.4, identical on 3.1.5; rows added in v0.29.0 on 2.7.0 and 3.3.4 in one process, identical on 3.1.5. The row added in v0.29.2 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. Rows added in v0.30.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.30.3 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. The row added in v0.30.7 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5: its parser refuses a statement that nests six objects, and `update()` nests at most four. Rows added in v0.31.0 were measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. The row added in v0.31.1 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. Rows added in v0.32.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4 but accepts raw writes to a view. Rows added in v0.33.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4. Rows added in v0.34.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4 except that it refuses a Python `set` written to a `set` field, and an object item of an optional untyped `list`. Rows added in v0.35.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.35.2 was measured on 2.7.0 and 3.3.4, identical on 3.1.5. The row added in v0.35.3 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. Rows added in v0.36.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.36.2 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. Rows added in v0.37.0 were measured on 2.7.0, 3.3.4, 3.2.6 and the embedded engine, with 3.1.5 and 3.2.6 where they differ from 3.3.4.
6827
+ Rows added in v0.20.0 were measured directly on 2.7.0 and 3.3.0; rows added in v0.21.0 on 2.7.0 and 3.3.2, re-verified on 3.3.3, with 3.1.5 where it differs; rows added in v0.22.0 on 2.7.0 and 3.3.3, with 3.1.5 where it differs; rows added in v0.23.0 on 2.7.0 and 3.3.4, with 3.1.5 where it differs; rows added in v0.24.0 on 2.7.0 and 3.3.4, identical on 3.1.5; rows added in v0.26.0 on 2.7.0 and 3.3.4, in memory and on versioned storage, identical on 3.1.5; rows added in v0.27.0 on 2.7.0 and 3.3.4, with 3.1.5 where it differs; rows added in v0.28.0 on 2.7.0 and 3.3.4, identical on 3.1.5; the rows added in v0.28.1 on 2.7.0 and 3.3.4, identical on 3.1.5; rows added in v0.29.0 on 2.7.0 and 3.3.4 in one process, identical on 3.1.5. The row added in v0.29.2 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. Rows added in v0.30.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.30.3 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. The row added in v0.30.7 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5: its parser refuses a statement that nests six objects, and `update()` nests at most four. Rows added in v0.31.0 were measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. The row added in v0.31.1 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. Rows added in v0.32.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4 but accepts raw writes to a view. Rows added in v0.33.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4. Rows added in v0.34.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4 except that it refuses a Python `set` written to a `set` field, and an object item of an optional untyped `list`. Rows added in v0.35.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.35.2 was measured on 2.7.0 and 3.3.4, identical on 3.1.5. The row added in v0.35.3 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. Rows added in v0.36.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.36.2 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. Rows added in v0.37.0 were measured on 2.7.0, 3.3.4, 3.2.6 and the embedded engine, with 3.1.5 and 3.2.6 where they differ from 3.3.4. The row added in v0.37.2 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5.
6825
6828
  The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded engine](#orm-behaviour-the-embedded-engine).
6826
6829
 
6827
6830
  | ORM capability | SurrealDB 2.6.x / 2.7.x | SurrealDB 3.2.x / 3.3.x | Since |
@@ -6866,6 +6869,7 @@ The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded
6866
6869
  | Signing in as a system user while a record session is open | permissions change, `$auth` still points at the record — only `invalidate()` clears it | 3.2.x: same as 2.x. **3.3.0**: the identity is cleared and `info()` returns `None`; `invalidate()` stays the portable log-out | v0.16.0 |
6867
6870
  | Duplicate signin identifier in the record table | signin fails (`No record was returned`) | signin succeeds, picking one record | v0.16.0 |
6868
6871
  | Model auth (`signup`/`signin`/`authenticate`, `access_ddl`/`define_access`) | same on both lines (verified on 2.6.5) | same on both lines (verified on 3.2.4) | v0.17.0 |
6872
+ | Model auth with a `primary_key` (`access_ddl()`, `define_access()`) | same on both lines: SIGNUP runs `CREATE <table> SET id = $<key>, …`, so the record id is the key (verified on 2.7.0) | same on both lines (verified on 3.3.4 and 3.1.5); v0.17.0 to v0.37.1 rendered `type::thing`, which 3.x refuses, so `define_access()` failed | v0.37.2 |
6869
6873
  | Model auth session isolation (each call on its own ephemeral connection) | same on both lines (an SDK/connection property, not a server one) | same on both lines (verified on 3.2.4) | v0.17.0 |
6870
6874
  | Hydrated instance's password field after `signup`/`signin` | holds the stored **hash**, never the plaintext | same on both lines | v0.17.0 |
6871
6875
  | Model config `with_refresh=True` → `define_access()` | raises `SurrealDbError` (clause does not parse; message names the 3.x requirement) | applies, and `AuthResult.tokens.refresh` is populated | v0.17.0 |
@@ -1246,7 +1246,9 @@ a concurrent server).
1246
1246
 
1247
1247
  The model must declare either an `id` field or a `primary_key`, as every ORM model must. Prefer
1248
1248
  `id` here so the server mints the record id during SIGNUP; configure `primary_key` when identity
1249
- _is_ a column, and the SIGNUP clause targets `type::thing(…)` to match.
1249
+ _is_ a column, and the SIGNUP clause sets the record id from it to match
1250
+ (`CREATE User SET id = $email, email = $email, …`): the same statement on SurrealDB 2.x, 3.x and the embedded engine,
1251
+ and the record id is the key on all of them.
1250
1252
 
1251
1253
  #### Configuration
1252
1254
 
@@ -4454,10 +4456,11 @@ reads, stores, logs or writes them.
4454
4456
  for a field without `TYPE`, as in the full ORM.
4455
4457
  - **Accesses are database-level**: they are in `schema.accesses`, and `TableState` has no `access` attribute; find
4456
4458
  a table's with `[a for a in schema.accesses.values() if a.table == "user"]`. `table`, `signup_fields` and
4457
- `signin_where` are read from `SIGNUP (CREATE <table> SET …)` (also `CREATE type::thing('<table>', …) SET …` and
4458
- `CREATE type::record('<table>', …) SET …`, the forms `define_access()` uses for a `primary_key`) and
4459
- `SIGNIN (SELECT … FROM <table> WHERE …)`. The full ORM reads the first form only, and another shape leaves them
4460
- empty, with field names unescaped; durations are kept as rendered, `'NONE'` included.
4459
+ `signin_where` are read from `SIGNUP (CREATE <table> SET …)` (the form `define_access()` uses, whose
4460
+ `id = $<key>` for a `primary_key` is one of the `signup_fields`; also `CREATE type::thing('<table>', …) SET …` and
4461
+ `CREATE type::record('<table>', …) SET …`) and `SIGNIN (SELECT … FROM <table> WHERE …)`. The full ORM reads the
4462
+ first form only, and another shape leaves them empty, with field names unescaped; durations are kept as rendered,
4463
+ `'NONE'` included.
4461
4464
  - **`encrypted` is not provided**: the lite has no `Encrypted` type, so a hashing `VALUE`
4462
4465
  (`crypto::argon2::generate($value)`) stays in `FieldState.value` and the field is generated as a writable field.
4463
4466
  - **APIs and the GraphQL config are not typed**: their definitions are in `SchemaState.other["apis"]` and
@@ -6770,7 +6773,7 @@ features introduced in SurrealDB 3.x. On 2.x the ORM degrades gracefully. Capabi
6770
6773
  listed behave the same on both lines. The 2.x column was measured on 2.6.5 and holds unchanged
6771
6774
  on 2.7.0. The 3.x column was measured on 3.2.4 and holds on 3.3.0, except where a row says
6772
6775
  otherwise. The full suite and every divergence below were re-verified on both new versions.
6773
- Rows added in v0.20.0 were measured directly on 2.7.0 and 3.3.0; rows added in v0.21.0 on 2.7.0 and 3.3.2, re-verified on 3.3.3, with 3.1.5 where it differs; rows added in v0.22.0 on 2.7.0 and 3.3.3, with 3.1.5 where it differs; rows added in v0.23.0 on 2.7.0 and 3.3.4, with 3.1.5 where it differs; rows added in v0.24.0 on 2.7.0 and 3.3.4, identical on 3.1.5; rows added in v0.26.0 on 2.7.0 and 3.3.4, in memory and on versioned storage, identical on 3.1.5; rows added in v0.27.0 on 2.7.0 and 3.3.4, with 3.1.5 where it differs; rows added in v0.28.0 on 2.7.0 and 3.3.4, identical on 3.1.5; the rows added in v0.28.1 on 2.7.0 and 3.3.4, identical on 3.1.5; rows added in v0.29.0 on 2.7.0 and 3.3.4 in one process, identical on 3.1.5. The row added in v0.29.2 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. Rows added in v0.30.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.30.3 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. The row added in v0.30.7 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5: its parser refuses a statement that nests six objects, and `update()` nests at most four. Rows added in v0.31.0 were measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. The row added in v0.31.1 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. Rows added in v0.32.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4 but accepts raw writes to a view. Rows added in v0.33.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4. Rows added in v0.34.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4 except that it refuses a Python `set` written to a `set` field, and an object item of an optional untyped `list`. Rows added in v0.35.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.35.2 was measured on 2.7.0 and 3.3.4, identical on 3.1.5. The row added in v0.35.3 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. Rows added in v0.36.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.36.2 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. Rows added in v0.37.0 were measured on 2.7.0, 3.3.4, 3.2.6 and the embedded engine, with 3.1.5 and 3.2.6 where they differ from 3.3.4.
6776
+ Rows added in v0.20.0 were measured directly on 2.7.0 and 3.3.0; rows added in v0.21.0 on 2.7.0 and 3.3.2, re-verified on 3.3.3, with 3.1.5 where it differs; rows added in v0.22.0 on 2.7.0 and 3.3.3, with 3.1.5 where it differs; rows added in v0.23.0 on 2.7.0 and 3.3.4, with 3.1.5 where it differs; rows added in v0.24.0 on 2.7.0 and 3.3.4, identical on 3.1.5; rows added in v0.26.0 on 2.7.0 and 3.3.4, in memory and on versioned storage, identical on 3.1.5; rows added in v0.27.0 on 2.7.0 and 3.3.4, with 3.1.5 where it differs; rows added in v0.28.0 on 2.7.0 and 3.3.4, identical on 3.1.5; the rows added in v0.28.1 on 2.7.0 and 3.3.4, identical on 3.1.5; rows added in v0.29.0 on 2.7.0 and 3.3.4 in one process, identical on 3.1.5. The row added in v0.29.2 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. Rows added in v0.30.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.30.3 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. The row added in v0.30.7 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5: its parser refuses a statement that nests six objects, and `update()` nests at most four. Rows added in v0.31.0 were measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. The row added in v0.31.1 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5. Rows added in v0.32.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4 but accepts raw writes to a view. Rows added in v0.33.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4. Rows added in v0.34.0 were measured on 2.7.0, 3.3.4 and the embedded engine; 3.1.5 behaves as 3.3.4 except that it refuses a Python `set` written to a `set` field, and an object item of an optional untyped `list`. Rows added in v0.35.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.35.2 was measured on 2.7.0 and 3.3.4, identical on 3.1.5. The row added in v0.35.3 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. Rows added in v0.36.0 were measured on 2.7.0, 3.3.4 and the embedded engine, with 3.1.5 where it differs. The row added in v0.36.2 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5. Rows added in v0.37.0 were measured on 2.7.0, 3.3.4, 3.2.6 and the embedded engine, with 3.1.5 and 3.2.6 where they differ from 3.3.4. The row added in v0.37.2 was measured on 2.7.0, 3.3.4 and the embedded engine, identical on 3.1.5.
6774
6777
  The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded engine](#orm-behaviour-the-embedded-engine).
6775
6778
 
6776
6779
  | ORM capability | SurrealDB 2.6.x / 2.7.x | SurrealDB 3.2.x / 3.3.x | Since |
@@ -6815,6 +6818,7 @@ The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded
6815
6818
  | Signing in as a system user while a record session is open | permissions change, `$auth` still points at the record — only `invalidate()` clears it | 3.2.x: same as 2.x. **3.3.0**: the identity is cleared and `info()` returns `None`; `invalidate()` stays the portable log-out | v0.16.0 |
6816
6819
  | Duplicate signin identifier in the record table | signin fails (`No record was returned`) | signin succeeds, picking one record | v0.16.0 |
6817
6820
  | Model auth (`signup`/`signin`/`authenticate`, `access_ddl`/`define_access`) | same on both lines (verified on 2.6.5) | same on both lines (verified on 3.2.4) | v0.17.0 |
6821
+ | Model auth with a `primary_key` (`access_ddl()`, `define_access()`) | same on both lines: SIGNUP runs `CREATE <table> SET id = $<key>, …`, so the record id is the key (verified on 2.7.0) | same on both lines (verified on 3.3.4 and 3.1.5); v0.17.0 to v0.37.1 rendered `type::thing`, which 3.x refuses, so `define_access()` failed | v0.37.2 |
6818
6822
  | Model auth session isolation (each call on its own ephemeral connection) | same on both lines (an SDK/connection property, not a server one) | same on both lines (verified on 3.2.4) | v0.17.0 |
6819
6823
  | Hydrated instance's password field after `signup`/`signin` | holds the stored **hash**, never the plaintext | same on both lines | v0.17.0 |
6820
6824
  | Model config `with_refresh=True` → `define_access()` | raises `SurrealDbError` (clause does not parse; message names the 3.x requirement) | applies, and `AuthResult.tokens.refresh` is populated | v0.17.0 |
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "surreal-orm-lite"
3
- version = "0.37.1"
3
+ version = "0.37.2"
4
4
  description = "Lightweight Django-style ORM for SurrealDB using the official Python SDK. Async support with Pydantic validation."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,4 +1,4 @@
1
- __version__ = "0.37.1"
1
+ __version__ = "0.37.2"
2
2
 
3
3
  from ._sdk import BoundExcluded, BoundIncluded
4
4
  from .aggregations import Aggregation, Avg, Count, Max, Min, Sum
@@ -2491,8 +2491,10 @@ def parse_define_access(text: str) -> AccessState:
2491
2491
  ``BEARER``) is read positionally, then the clauses ``SIGNUP``, ``SIGNIN``, ``WITH REFRESH``, ``WITH JWT``,
2492
2492
  ``ALGORITHM``, ``URL``, ``WITH ISSUER``, ``AUTHENTICATE``, ``DURATION`` and ``COMMENT``. ``signup`` and ``signin``
2493
2493
  keep their groups, parentheses included. ``table`` and ``signup_fields`` come from a SIGNUP ``CREATE <target> SET
2494
- <field> = <expr>, …`` whose target is a table name or a guarded ``type::thing('<table>', …)`` /
2495
- ``type::record('<table>', …)`` call; ``signin_where`` from a SIGNIN ``SELECT … FROM <table> WHERE <expr>``; any
2494
+ <field> = <expr>, …`` whose target is a table name — ``define_access()``'s form, whose ``id = $<key>`` item for a
2495
+ ``primary_key`` is one of the ``signup_fields`` — or a guarded ``type::thing('<table>', …)`` /
2496
+ ``type::record('<table>', …)`` call (the ORM's ``primary_key`` form before #338, or one written by hand), every
2497
+ ``SET`` item read; ``signin_where`` from a SIGNIN ``SELECT … FROM <table> WHERE <expr>``; any
2496
2498
  other shape gives ``""`` and ``{}``, with no error (the full ORM's attributes, made exact). Durations are kept as
2497
2499
  rendered (``"4w2d"``, ``"NONE"``), ``None`` for one the ``DURATION`` clause does not name. The servers render the
2498
2500
  keys ``[REDACTED]``. Raises ``DefineParseError``.
@@ -170,7 +170,8 @@ class AuthenticatedUserMixin:
170
170
  a ``primary_key`` — otherwise the instance these methods return cannot be constructed at
171
171
  all. Prefer the ``id`` field here: SIGNUP lets the server mint the record id, and this is
172
172
  what receives it. Configure ``primary_key`` instead when the identity *is* a column (say
173
- the e-mail address), and the SIGNUP clause will target ``type::thing(…)`` accordingly.
173
+ the e-mail address), and the SIGNUP clause will set the record id from it (``id = $email``)
174
+ accordingly — the same statement on SurrealDB 3.x, 2.x and the embedded engine.
174
175
  """
175
176
 
176
177
  # ------------------------------------------------------------------
@@ -303,11 +304,12 @@ class AuthenticatedUserMixin:
303
304
  def _signup_primary_key(cls) -> str | None:
304
305
  """The primary key SIGNUP builds the record id from, or ``None`` for a server id.
305
306
 
306
- The key has to be *bindable*: SIGNUP renders ``type::thing(table, $pk)``, so a key that
307
- is not among the fields signup sends would evaluate to ``type::thing(table, NONE)`` and
308
- fail server-side with an opaque error. ``primary_key="id"`` is the trap — ``id`` is
309
- deliberately excluded from the signup payload (the server mints it), so it can never be
310
- bound. Caught here, at render time, rather than on every signup.
307
+ The key has to be *bindable*: SIGNUP renders ``CREATE <table> SET id = $pk, …``, so a key
308
+ that is not among the fields signup sends would evaluate to ``id = NONE`` and have the
309
+ server mint a random record id — one no ``objects().get(<key>)`` addresses.
310
+ ``primary_key="id"`` is the trap — ``id`` is deliberately excluded from the signup
311
+ payload (the server mints it), so it can never be bound. Caught here, at render time,
312
+ rather than on every signup.
311
313
  """
312
314
  primary_key = cls.get_index_primary_key() # type: ignore[attr-defined]
313
315
  if primary_key is None:
@@ -385,6 +387,12 @@ class AuthenticatedUserMixin:
385
387
  ``define_table()`` writes ``TYPE NORMAL``, so calling both changes the type each time.
386
388
  Declaring ``table_type`` gives both the same type.
387
389
 
390
+ A model with a ``primary_key`` has SIGNUP create the record whose id is the key:
391
+ ``CREATE <table> SET id = $<key>, …``, the assignment first (#338). The statements are
392
+ the same for SurrealDB 3.x, 2.x and the embedded engine — a function building the id
393
+ would not be: 3.x refuses ``type::thing`` at ``DEFINE``, and 2.x reads
394
+ ``type::record(table, key)`` as a type check that fails every signup.
395
+
388
396
  Args:
389
397
  overwrite: ``True`` (default) emits ``OVERWRITE`` — the model is the source of
390
398
  truth, so re-running converges the database onto the code. ``False`` emits
@@ -451,9 +459,13 @@ class AuthenticatedUserMixin:
451
459
 
452
460
  # The record id follows the model's primary key, because the rest of the ORM does: a
453
461
  # random id here would leave User.objects().get(email=…) addressing a record the
454
- # signup never wrote.
462
+ # signup never wrote. It is assigned from the bound key (`id = $<key>`, first item of
463
+ # the SET), not built with a function: SurrealDB 3.x refuses `type::thing` at DEFINE,
464
+ # and 2.x reads `type::record(table, key)` as a type check that fails every signup
465
+ # (#338), while the assignment gives the record id `<table>:<key>` on both lines and on
466
+ # the embedded engine.
455
467
  primary_key = cls._signup_primary_key()
456
- target = f"type::thing('{table}', ${primary_key})" if primary_key is not None else table
468
+ items = [] if primary_key is None else [f"id = ${primary_key}"]
457
469
 
458
470
  # Column on the left of each assignment, bound variable on the right: the variable
459
471
  # keeps the Python name the caller passes as a keyword argument, while the column is
@@ -462,16 +474,16 @@ class AuthenticatedUserMixin:
462
474
  # `password_hash` — signin would then keep validating against a hash no ORM write ever
463
475
  # updates.
464
476
  to_column = cls.to_db_field # type: ignore[attr-defined]
465
- assignments = ", ".join(
477
+ items += [
466
478
  f"{to_column(name)} = crypto::{algorithm}::generate(${name})"
467
479
  if name == password
468
480
  else f"{to_column(name)} = ${name}"
469
481
  for name in cls._signup_fields()
470
- )
482
+ ]
471
483
 
472
484
  parts = [
473
485
  f"DEFINE ACCESS {clause} {access} ON DATABASE TYPE RECORD",
474
- f"SIGNUP ( CREATE {target} SET {assignments} )",
486
+ f"SIGNUP ( CREATE {table} SET {', '.join(items)} )",
475
487
  f"SIGNIN ( SELECT * FROM {table} WHERE {to_column(identifier)} = ${identifier} "
476
488
  f"AND crypto::{algorithm}::compare({to_column(password)}, ${password}) )",
477
489
  ]
@@ -654,6 +666,14 @@ class AuthenticatedUserMixin:
654
666
  f"They have no default, so the instance could not be built from the record "
655
667
  f"the server would create."
656
668
  )
669
+ # The record id SIGNUP creates is the primary key's value (`SET id = $<key>`, #338): a
670
+ # `None` there has the server mint a random id, one no objects().get(<key>) addresses —
671
+ # refused before the exchange as well.
672
+ primary_key = cls.get_index_primary_key() # type: ignore[attr-defined]
673
+ if primary_key in payload and payload[primary_key] is None:
674
+ raise ValueError(
675
+ f"{cls.__name__}.{action}() requires {primary_key}=: it is the primary key, which SIGNUP makes the record id."
676
+ )
657
677
  return payload
658
678
 
659
679
  @classmethod
@@ -964,7 +984,8 @@ class AuthenticatedUserMixin:
964
984
  would strip of its password hash. :meth:`signin`, :meth:`authenticate`,
965
985
  :meth:`refresh`, ``update()`` and ``upsert()`` refuse such a model the same way
966
986
  (#310), whoever wrote the record.
967
- ValueError: for an unknown field or a missing required one — before any request.
987
+ ValueError: for an unknown field, a missing required one, or a ``primary_key`` left
988
+ ``None`` (it is the record id SIGNUP creates) — before any request.
968
989
  SurrealDbAuthenticationError: if the server refuses the signup, or returns no
969
990
  record for the new session (the message says how to grant the permission).
970
991
  SurrealDbError: on the embedded engine without ``bind=True``.
@@ -279,8 +279,9 @@ class AccessState:
279
279
  ``signup_fields``, ``signin_where``, ``duration_token``, ``duration_session``, ``access_type``,
280
280
  ``duration_grant``. Lite additions, keyword-only: ``signup``, ``signin``, ``with_refresh``, ``comment``, ``raw``.
281
281
 
282
- ``table`` and ``signup_fields`` come from a ``SIGNUP (CREATE <table> SET <field> = <expr>, …)``, ``signin_where``
283
- from a ``SIGNIN (SELECT … FROM <table> WHERE <expr>)`` (``""``/empty otherwise). Durations are kept as rendered
282
+ ``table`` and ``signup_fields`` come from a ``SIGNUP (CREATE <table> SET <field> = <expr>, …)`` — every item,
283
+ the ``id = $<key>`` of a model with a ``primary_key`` included —, ``signin_where`` from a ``SIGNIN (SELECT … FROM
284
+ <table> WHERE <expr>)`` (``""``/empty otherwise). Durations are kept as rendered
284
285
  (``"15m"``, ``"NONE"``). The keys of a ``raw`` statement are already ``[REDACTED]`` by the server; ``raw``,
285
286
  ``signup``, ``signin`` and ``signin_where`` are kept out of ``repr`` all the same, and ``signup_fields`` shows its
286
287
  keys only.