surreal-orm-lite 0.36.1__tar.gz → 0.36.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.
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/CHANGELOG.md +44 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/PKG-INFO +16 -5
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/README.md +15 -4
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/pyproject.toml +1 -1
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/__init__.py +1 -1
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/model_base.py +48 -18
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/transaction.py +29 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/.gitignore +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/LICENSE +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/Makefile +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/_sdk.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/aggregations.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/auth.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/cache.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/changefeed.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/concurrency.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/connection_config.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/connection_manager.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/constants.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/decoding.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/define_parser.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/edge.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/embedded.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/encoding.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/enum.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/exceptions.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/functions.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/geo.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/introspection.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/live.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/model_auth.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/model_ddl.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/model_generator.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/py.typed +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/q.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/query_set.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/routing.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/schema.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/schema_state.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/search.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/signals.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/subquery.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/surql_literal.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/testing/__init__.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/testing/database.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/testing/fixtures.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/time_travel.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/types.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/utils.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/vector.py +0 -0
|
@@ -5,6 +5,50 @@ 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.36.2] - 2026-10-23
|
|
9
|
+
|
|
10
|
+
Follow-ups to the review of v0.35.3 (#312): an index that `remove_index(tx=…)` removed earlier in
|
|
11
|
+
a transaction is defined again by `define_indexes(tx=…)` in the same block instead of being lost
|
|
12
|
+
at the commit, and the docs say why the refusal after a write covers every kind of index. No new
|
|
13
|
+
public API.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **`remove_index(tx=…)` then `define_indexes(tx=…)` in one block no longer loses an existing
|
|
18
|
+
index** (#312). `define_indexes(tx=…)` reads `INFO FOR TABLE` outside the transaction, where an
|
|
19
|
+
index removed earlier in the block still stands: it planned nothing, returned `[]`, and the
|
|
20
|
+
commit applied the removal, leaving the table without the index and without an error (since
|
|
21
|
+
v0.35.0, over WebSocket and HTTP and on the embedded engine, on SurrealDB 2.x and 3.x).
|
|
22
|
+
`remove_index(tx=…)` now notes the removal on the transaction, and `define_indexes(tx=…)`
|
|
23
|
+
counts the noted index as missing: it defines it again after the removal
|
|
24
|
+
(`DEFINE INDEX OVERWRITE`, or `IF NOT EXISTS` with `overwrite=False`), so the commit keeps
|
|
25
|
+
it, and a later call in the block compares it with committed state again. Only an index the
|
|
26
|
+
model declares comes back: another model's index on the same table comes back with that
|
|
27
|
+
model's `define_indexes(tx=…)`, and one no model declares stays removed. When the block has
|
|
28
|
+
already written records to the table, the call is refused before any DDL, as since v0.35.3. A
|
|
29
|
+
raw `tx.add("REMOVE INDEX …")` is not tracked.
|
|
30
|
+
- **The same fix also applies to vector (HNSW) indexes since v0.36.0**: on v0.36.0 and v0.36.1,
|
|
31
|
+
`remove_index(tx=…)` then `define_indexes(tx=…)` lost an HNSW index at the commit on every
|
|
32
|
+
engine; it is now defined again, as a full-text or `UNIQUE` index is.
|
|
33
|
+
|
|
34
|
+
### Notes
|
|
35
|
+
|
|
36
|
+
- **Removing an index and defining it again in one block on SurrealDB 2.x**: on a table that
|
|
37
|
+
held records, the commit fails with a retryable `SurrealDbConflictError` that a retry meets
|
|
38
|
+
again, a 2.x limitation; nothing of the block is committed and the index stands as before. On an
|
|
39
|
+
empty table it commits, as on SurrealDB 3.x and the embedded engine. A row in each behaviour
|
|
40
|
+
table of the README ("ORM behaviour: SurrealDB 2.x vs 3.x" and the embedded engine's) describes
|
|
41
|
+
each engine's outcome, which tests pin.
|
|
42
|
+
- **A write after `define_indexes(tx=…)` on SurrealDB 2.x**: the v0.35.3 qualifier "to a table
|
|
43
|
+
that held records" is now pinned: on an empty table, a write after the index in the same block
|
|
44
|
+
commits and is indexed.
|
|
45
|
+
- **Docs**: README section 36 (Transactions) and the `define_indexes()` docstring say why the
|
|
46
|
+
refusal after a write covers every kind of index, not only full-text ones: a search would miss
|
|
47
|
+
those records, and a `UNIQUE` index missing them would not enforce uniqueness for them
|
|
48
|
+
([surrealdb/surrealdb#7618](https://github.com/surrealdb/surrealdb/issues/7618)).
|
|
49
|
+
- Server pins unchanged: tested against SurrealDB 3.3.4 and 2.7.0 and on the embedded engine,
|
|
50
|
+
plus 3.1.5 for backward compatibility.
|
|
51
|
+
|
|
8
52
|
## [0.36.1] - 2026-10-23
|
|
9
53
|
|
|
10
54
|
Follow-ups to the review of v0.35.4 (#315): an instance write that the model refuses (a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: surreal-orm-lite
|
|
3
|
-
Version: 0.36.
|
|
3
|
+
Version: 0.36.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
|
|
@@ -6087,6 +6087,11 @@ print(await NoteV2.objects().search(text="physics").count())
|
|
|
6087
6087
|
SurrealDB 3.x), at the commit in a buffered one (HTTP, SurrealDB 2.x, the embedded engine), where a refusal comes
|
|
6088
6088
|
back as the transaction's own `SurrealDbError`. A block that raises applies nothing. `remove_index(tx=…)` joins it
|
|
6089
6089
|
the same way.
|
|
6090
|
+
- An index `remove_index(tx=…)` removed earlier in the block counts as missing, although committed state still holds
|
|
6091
|
+
it: `define_indexes(tx=…)` defines it again after its removal (`OVERWRITE`, or `IF NOT EXISTS` with
|
|
6092
|
+
`overwrite=False`), so the commit keeps it. Only an index the model declares comes back: another model's on the same
|
|
6093
|
+
table comes back with that model's `define_indexes(tx=…)`, and one no model declares stays removed. A raw
|
|
6094
|
+
`tx.add("REMOVE INDEX …")` is not tracked.
|
|
6090
6095
|
- The analyzers must be in place: SurrealDB builds an index with the analyzers committed before the transaction began.
|
|
6091
6096
|
So `define_indexes(tx=…)` raises `SurrealDbError` before any DDL when an analyzer must be defined or redefined, and
|
|
6092
6097
|
`define_analyzer(tx=…)` when a redefinition has indexes to rebuild (a new analyzer, or a redefinition no index uses,
|
|
@@ -6095,11 +6100,15 @@ print(await NoteV2.objects().search(text="physics").count())
|
|
|
6095
6100
|
wrote before the index was defined, which stay out of it after the commit. It is a server defect
|
|
6096
6101
|
([surrealdb/surrealdb#7618](https://github.com/surrealdb/surrealdb/issues/7618) on 3.x, the same on 2.x); only the
|
|
6097
6102
|
embedded engine indexes them. So `define_indexes(tx=…)` raises `SurrealDbError` before any DDL, naming the model and
|
|
6098
|
-
the table, when an index must be defined or redefined
|
|
6099
|
-
with the ORM (`save()`, `objects(tx=…).bulk_create()`, …). The
|
|
6103
|
+
the table, when an index must be defined or redefined — one removed earlier in the block included — and the block
|
|
6104
|
+
has already written records to the model's table with the ORM (`save()`, `objects(tx=…).bulk_create()`, …). The
|
|
6105
|
+
refusal covers every kind of index, not only full-text ones: a search would miss those records, and a `UNIQUE` index
|
|
6106
|
+
missing them would not enforce uniqueness for them. The refusal does not fail the block. `define_table(tx=…)`,
|
|
6100
6107
|
`define_relation(tx=…)` and a write to another table do not count; a raw `tx.add()` is not tracked.
|
|
6101
6108
|
- Prefer `define_indexes()` outside the block: on SurrealDB 2.x, a write to a table that held records, after its index
|
|
6102
|
-
in the same block, fails the commit with a retryable `SurrealDbConflictError` that a retry meets again
|
|
6109
|
+
in the same block, fails the commit with a retryable `SurrealDbConflictError` that a retry meets again; so does a
|
|
6110
|
+
block that removes an index of a table that held records and defines it again, where the index stands as before.
|
|
6111
|
+
Nothing of such a block is committed. On an empty table both commit, as on 3.x.
|
|
6103
6112
|
- `remove_analyzer(tx=…)` reads committed state to find the indexes that use the analyzer: an index queued earlier in
|
|
6104
6113
|
a buffered block is not seen.
|
|
6105
6114
|
- A search in an interactive transaction sees the transaction's writes; in a buffered one, a read raises, as every
|
|
@@ -6597,7 +6606,7 @@ features introduced in SurrealDB 3.x. On 2.x the ORM degrades gracefully. Capabi
|
|
|
6597
6606
|
listed behave the same on both lines. The 2.x column was measured on 2.6.5 and holds unchanged
|
|
6598
6607
|
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
|
|
6599
6608
|
otherwise. The full suite and every divergence below were re-verified on both new versions.
|
|
6600
|
-
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.
|
|
6609
|
+
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.
|
|
6601
6610
|
The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded engine](#orm-behaviour-the-embedded-engine).
|
|
6602
6611
|
|
|
6603
6612
|
| ORM capability | SurrealDB 2.6.x / 2.7.x | SurrealDB 3.2.x / 3.3.x | Since |
|
|
@@ -6757,6 +6766,7 @@ The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded
|
|
|
6757
6766
|
| `similar_to()` with a condition that keeps few records | HNSW is approximate: fewer than `limit` records, depending on how the index was built, even with a tenth of the table kept; `dist=` is exact | rarer; also seen with a `Subquery` id list keeping a few percent of the table | v0.36.0 |
|
|
6758
6767
|
| `similar_to(dist=…)` with a condition on a linked record's field | the ORM selects the matching records first (a `LET`): 2.x's exact scan would return every matching record, ignoring `limit` | the condition stays next to the KNN operator | v0.36.0 |
|
|
6759
6768
|
| `similar_to()` on a field without a vector index | no record | no record; 3.1 answers every record, with no distance | v0.36.0 |
|
|
6769
|
+
| `remove_index(tx=)` then `define_indexes(tx=)` in one block, the index stored before the block | on a table holding records, the commit fails with a retryable `SurrealDbConflictError`, again on retry: nothing committed, the index kept; on an empty table, defined again | the index is defined again after its removal and committed, serving the records committed before the block | v0.36.2 |
|
|
6760
6770
|
| Full suite and every divergence in this table, re-run on SurrealDB 2.7.0 and 3.3.0 | 2.7.0 identical to 2.6.5 (same passes, same 3.x-only skips) | 3.3.0 identical to 3.2.4, except the system-user signin row | v0.19.1 |
|
|
6761
6771
|
|
|
6762
6772
|
> **Note on record IDs**: A record loaded from the database has its `id` field set to a native `surrealdb.RecordID` object, not a plain string. Use `model.get_raw_id()` to obtain the bare identifier string (e.g. `"alice"`), or compare directly with `model.id == RecordID("User", "alice")`. In-memory instances you construct yourself retain whatever value you assign.
|
|
@@ -6796,6 +6806,7 @@ Capabilities not listed behave as on a 2.x server.
|
|
|
6796
6806
|
| Full-text search (v0.35.0) | as on a 2.x server: `SEARCH ANALYZER`, a term in more than half the documents scores below zero, BM25 statistics grow with each rebuild and keep deleted records, `remove_analyzer()` refuses an analyzer an index uses; an index defined in the transaction that defines its analyzer sees it, which `define_indexes(tx=…)` refuses all the same | 3.x writes `FULLTEXT ANALYZER`, scores such a term `0.0`, keeps BM25 statistics exact and refuses that removal | v0.35.0 |
|
|
6797
6807
|
| `define_indexes(tx=)` in a block that writes to the model's table | an ORM write before it: refused all the same, although this engine indexes its records; a write after it is committed and indexed | refused (left out of the index); on 2.x a write after it, to a table holding records, fails the commit | v0.35.3 |
|
|
6798
6808
|
| Vector search (v0.36.0) | as on a 2.x server: `MTREE` accepted, at most `ef` records returned (the ORM raises `ef` to `limit`), other conditions selected first in a `LET` (search annotations refused), writes made by the ids of the nearest, fewer records with a selective condition; an index without `TYPE` is `F64` (servers: `F32`), so the ORM always writes `TYPE` | 3.x refuses `MTREE`, applies the conditions during the index search and keeps search annotations | v0.36.0 |
|
|
6809
|
+
| `remove_index(tx=)` then `define_indexes(tx=)` in one block | the index is defined again after its removal and committed, on a table holding records too | the same on 3.x; on 2.x, on a table holding records, the commit fails with a retryable conflict | v0.36.2 |
|
|
6799
6810
|
| Everything else | CRUD, QuerySet, aggregations, relations, typed edges, rich and geo fields, upsert/patch, server values, computed fields, stored functions, signals: the same as on a 2.x server | unchanged | v0.25.0 |
|
|
6800
6811
|
|
|
6801
6812
|
---
|
|
@@ -6036,6 +6036,11 @@ print(await NoteV2.objects().search(text="physics").count())
|
|
|
6036
6036
|
SurrealDB 3.x), at the commit in a buffered one (HTTP, SurrealDB 2.x, the embedded engine), where a refusal comes
|
|
6037
6037
|
back as the transaction's own `SurrealDbError`. A block that raises applies nothing. `remove_index(tx=…)` joins it
|
|
6038
6038
|
the same way.
|
|
6039
|
+
- An index `remove_index(tx=…)` removed earlier in the block counts as missing, although committed state still holds
|
|
6040
|
+
it: `define_indexes(tx=…)` defines it again after its removal (`OVERWRITE`, or `IF NOT EXISTS` with
|
|
6041
|
+
`overwrite=False`), so the commit keeps it. Only an index the model declares comes back: another model's on the same
|
|
6042
|
+
table comes back with that model's `define_indexes(tx=…)`, and one no model declares stays removed. A raw
|
|
6043
|
+
`tx.add("REMOVE INDEX …")` is not tracked.
|
|
6039
6044
|
- The analyzers must be in place: SurrealDB builds an index with the analyzers committed before the transaction began.
|
|
6040
6045
|
So `define_indexes(tx=…)` raises `SurrealDbError` before any DDL when an analyzer must be defined or redefined, and
|
|
6041
6046
|
`define_analyzer(tx=…)` when a redefinition has indexes to rebuild (a new analyzer, or a redefinition no index uses,
|
|
@@ -6044,11 +6049,15 @@ print(await NoteV2.objects().search(text="physics").count())
|
|
|
6044
6049
|
wrote before the index was defined, which stay out of it after the commit. It is a server defect
|
|
6045
6050
|
([surrealdb/surrealdb#7618](https://github.com/surrealdb/surrealdb/issues/7618) on 3.x, the same on 2.x); only the
|
|
6046
6051
|
embedded engine indexes them. So `define_indexes(tx=…)` raises `SurrealDbError` before any DDL, naming the model and
|
|
6047
|
-
the table, when an index must be defined or redefined
|
|
6048
|
-
with the ORM (`save()`, `objects(tx=…).bulk_create()`, …). The
|
|
6052
|
+
the table, when an index must be defined or redefined — one removed earlier in the block included — and the block
|
|
6053
|
+
has already written records to the model's table with the ORM (`save()`, `objects(tx=…).bulk_create()`, …). The
|
|
6054
|
+
refusal covers every kind of index, not only full-text ones: a search would miss those records, and a `UNIQUE` index
|
|
6055
|
+
missing them would not enforce uniqueness for them. The refusal does not fail the block. `define_table(tx=…)`,
|
|
6049
6056
|
`define_relation(tx=…)` and a write to another table do not count; a raw `tx.add()` is not tracked.
|
|
6050
6057
|
- Prefer `define_indexes()` outside the block: on SurrealDB 2.x, a write to a table that held records, after its index
|
|
6051
|
-
in the same block, fails the commit with a retryable `SurrealDbConflictError` that a retry meets again
|
|
6058
|
+
in the same block, fails the commit with a retryable `SurrealDbConflictError` that a retry meets again; so does a
|
|
6059
|
+
block that removes an index of a table that held records and defines it again, where the index stands as before.
|
|
6060
|
+
Nothing of such a block is committed. On an empty table both commit, as on 3.x.
|
|
6052
6061
|
- `remove_analyzer(tx=…)` reads committed state to find the indexes that use the analyzer: an index queued earlier in
|
|
6053
6062
|
a buffered block is not seen.
|
|
6054
6063
|
- A search in an interactive transaction sees the transaction's writes; in a buffered one, a read raises, as every
|
|
@@ -6546,7 +6555,7 @@ features introduced in SurrealDB 3.x. On 2.x the ORM degrades gracefully. Capabi
|
|
|
6546
6555
|
listed behave the same on both lines. The 2.x column was measured on 2.6.5 and holds unchanged
|
|
6547
6556
|
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
|
|
6548
6557
|
otherwise. The full suite and every divergence below were re-verified on both new versions.
|
|
6549
|
-
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.
|
|
6558
|
+
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.
|
|
6550
6559
|
The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded engine](#orm-behaviour-the-embedded-engine).
|
|
6551
6560
|
|
|
6552
6561
|
| ORM capability | SurrealDB 2.6.x / 2.7.x | SurrealDB 3.2.x / 3.3.x | Since |
|
|
@@ -6706,6 +6715,7 @@ The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded
|
|
|
6706
6715
|
| `similar_to()` with a condition that keeps few records | HNSW is approximate: fewer than `limit` records, depending on how the index was built, even with a tenth of the table kept; `dist=` is exact | rarer; also seen with a `Subquery` id list keeping a few percent of the table | v0.36.0 |
|
|
6707
6716
|
| `similar_to(dist=…)` with a condition on a linked record's field | the ORM selects the matching records first (a `LET`): 2.x's exact scan would return every matching record, ignoring `limit` | the condition stays next to the KNN operator | v0.36.0 |
|
|
6708
6717
|
| `similar_to()` on a field without a vector index | no record | no record; 3.1 answers every record, with no distance | v0.36.0 |
|
|
6718
|
+
| `remove_index(tx=)` then `define_indexes(tx=)` in one block, the index stored before the block | on a table holding records, the commit fails with a retryable `SurrealDbConflictError`, again on retry: nothing committed, the index kept; on an empty table, defined again | the index is defined again after its removal and committed, serving the records committed before the block | v0.36.2 |
|
|
6709
6719
|
| Full suite and every divergence in this table, re-run on SurrealDB 2.7.0 and 3.3.0 | 2.7.0 identical to 2.6.5 (same passes, same 3.x-only skips) | 3.3.0 identical to 3.2.4, except the system-user signin row | v0.19.1 |
|
|
6710
6720
|
|
|
6711
6721
|
> **Note on record IDs**: A record loaded from the database has its `id` field set to a native `surrealdb.RecordID` object, not a plain string. Use `model.get_raw_id()` to obtain the bare identifier string (e.g. `"alice"`), or compare directly with `model.id == RecordID("User", "alice")`. In-memory instances you construct yourself retain whatever value you assign.
|
|
@@ -6745,6 +6755,7 @@ Capabilities not listed behave as on a 2.x server.
|
|
|
6745
6755
|
| Full-text search (v0.35.0) | as on a 2.x server: `SEARCH ANALYZER`, a term in more than half the documents scores below zero, BM25 statistics grow with each rebuild and keep deleted records, `remove_analyzer()` refuses an analyzer an index uses; an index defined in the transaction that defines its analyzer sees it, which `define_indexes(tx=…)` refuses all the same | 3.x writes `FULLTEXT ANALYZER`, scores such a term `0.0`, keeps BM25 statistics exact and refuses that removal | v0.35.0 |
|
|
6746
6756
|
| `define_indexes(tx=)` in a block that writes to the model's table | an ORM write before it: refused all the same, although this engine indexes its records; a write after it is committed and indexed | refused (left out of the index); on 2.x a write after it, to a table holding records, fails the commit | v0.35.3 |
|
|
6747
6757
|
| Vector search (v0.36.0) | as on a 2.x server: `MTREE` accepted, at most `ef` records returned (the ORM raises `ef` to `limit`), other conditions selected first in a `LET` (search annotations refused), writes made by the ids of the nearest, fewer records with a selective condition; an index without `TYPE` is `F64` (servers: `F32`), so the ORM always writes `TYPE` | 3.x refuses `MTREE`, applies the conditions during the index search and keeps search annotations | v0.36.0 |
|
|
6758
|
+
| `remove_index(tx=)` then `define_indexes(tx=)` in one block | the index is defined again after its removal and committed, on a table holding records too | the same on 3.x; on 2.x, on a table holding records, the commit fails with a retryable conflict | v0.36.2 |
|
|
6748
6759
|
| Everything else | CRUD, QuerySet, aggregations, relations, typed edges, rich and geo fields, upsert/patch, server values, computed fields, stored functions, signals: the same as on a 2.x server | unchanged | v0.25.0 |
|
|
6749
6760
|
|
|
6750
6761
|
---
|
|
@@ -1304,19 +1304,31 @@ class BaseSurrealModel(BaseModel):
|
|
|
1304
1304
|
Before any DDL (nothing sent but the reads): an index that names by ``str`` an analyzer neither the database
|
|
1305
1305
|
nor the model's ``Analyzer`` objects define is refused; with *tx*, an analyzer to define or redefine is refused
|
|
1306
1306
|
— SurrealDB builds an index with the analyzers committed before the transaction began: define it first,
|
|
1307
|
-
outside the block. With *tx*, an index to define or redefine
|
|
1308
|
-
written records to the model's table — an ORM write (``save()``,
|
|
1309
|
-
noted on every table; a definition such as ``define_table(tx=…)``
|
|
1310
|
-
which the ORM does not track: SurrealDB servers do not index the
|
|
1311
|
-
was defined, which stay out of it after the commit — a server
|
|
1312
|
-
same on 2.x; the embedded engine indexes them).
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1307
|
+
outside the block. With *tx*, an index to define or redefine (one removed in the block included) is also refused
|
|
1308
|
+
when the transaction has already written records to the model's table — an ORM write (``save()``,
|
|
1309
|
+
``objects(tx=…).bulk_create()``, …) or one noted on every table; a definition such as ``define_table(tx=…)``
|
|
1310
|
+
does not count, nor does a raw ``tx.add()``, which the ORM does not track: SurrealDB servers do not index the
|
|
1311
|
+
records a transaction wrote before the index was defined, which stay out of it after the commit — a server
|
|
1312
|
+
defect (surrealdb/surrealdb#7618 on 3.x, the same on 2.x; the embedded engine indexes them). Every kind of
|
|
1313
|
+
index is refused, not only a full-text one: a search would miss those records, and a ``UNIQUE`` index would
|
|
1314
|
+
not enforce uniqueness for them. The refusal does not fail the transaction; call ``define_indexes()`` without
|
|
1315
|
+
*tx* first. With *tx* and the analyzers in place, the index statements join the transaction — applied at once
|
|
1316
|
+
in an interactive one (WebSocket, SurrealDB 3.x), at the commit in a buffered one (HTTP, SurrealDB 2.x, the
|
|
1317
|
+
embedded engine), where a refusal comes back as the transaction's own error; a block that raises applies
|
|
1318
|
+
nothing. On SurrealDB 2.x, a write to a table that held records, after its index in the same block, fails the
|
|
1319
|
+
commit with a retryable ``SurrealDbConflictError`` that a retry meets again; on an empty table it commits, as on
|
|
1320
|
+
3.x. In a buffered transaction an index queued earlier in the block is not seen by the reads, and is queued
|
|
1321
|
+
again (the same statement). Every cached read is dropped.
|
|
1322
|
+
|
|
1323
|
+
**An index removed in the transaction.** With *tx*, an index :meth:`remove_index` removed with the same *tx*
|
|
1324
|
+
counts as missing, although the committed state the reads see still holds it: it is defined again after its
|
|
1325
|
+
removal (``DEFINE INDEX OVERWRITE``, or ``IF NOT EXISTS`` without *overwrite*), so the commit keeps it; a later
|
|
1326
|
+
call in the block compares it with committed state again. Only an index this model declares is defined again:
|
|
1327
|
+
another model's on the same table comes back with that model's ``define_indexes(tx=…)``, and one no model
|
|
1328
|
+
declares stays removed. A raw ``tx.add("REMOVE INDEX …")`` is not tracked. On SurrealDB 2.x, on a table that
|
|
1329
|
+
held records, a block that removes an index and defines it again fails the commit with a retryable
|
|
1330
|
+
``SurrealDbConflictError`` that a retry meets again: nothing of the block is committed and the index stands as
|
|
1331
|
+
before; on an empty table it commits, as on 3.x.
|
|
1320
1332
|
|
|
1321
1333
|
Names are written in backticks, filters re-rendered from a closed grammar, numbers from Python numbers,
|
|
1322
1334
|
comments as string literals. A refusal names the analyzer or the index and its table, never the statement:
|
|
@@ -1328,15 +1340,16 @@ class BaseSurrealModel(BaseModel):
|
|
|
1328
1340
|
overwrite: ``True`` (default) redefines a changed analyzer or index — the model wins. ``False`` defines
|
|
1329
1341
|
what is missing (``IF NOT EXISTS``) and leaves what exists as it is.
|
|
1330
1342
|
tx: optional transaction the index statements are applied with; the reads happen before anything is
|
|
1331
|
-
queued.
|
|
1343
|
+
queued. An index :meth:`remove_index` removed with it counts as missing.
|
|
1332
1344
|
|
|
1333
1345
|
Raises:
|
|
1334
1346
|
TypeError: *overwrite* is not a ``bool`` — before any request.
|
|
1335
1347
|
SurrealDbError: *tx* belongs to another connection — before any request; an analyzer named by ``str`` does
|
|
1336
1348
|
not exist, or *tx* is given and an analyzer must be defined or redefined, or an index must be defined
|
|
1337
|
-
or redefined after the transaction wrote records to the model's
|
|
1338
|
-
the table) — before any DDL; the server refused a statement
|
|
1339
|
-
``Can't apply
|
|
1349
|
+
or redefined (one removed in the block included) after the transaction wrote records to the model's
|
|
1350
|
+
table (the message names the model and the table) — before any DDL; the server refused a statement
|
|
1351
|
+
(``Can't apply analyzer definition: …``, ``Can't apply index definition: …``, ``Can't apply index
|
|
1352
|
+
rebuild: …``).
|
|
1340
1353
|
SurrealDbAuthenticationError: the session may not read the definitions or define the analyzers and
|
|
1341
1354
|
indexes.
|
|
1342
1355
|
|
|
@@ -1377,6 +1390,11 @@ class BaseSurrealModel(BaseModel):
|
|
|
1377
1390
|
if any(index.search_analyzer is not None for index in indexes):
|
|
1378
1391
|
keyword = fulltext_keyword(_time_travel.line_major(await client.version()))
|
|
1379
1392
|
stored_indexes = await read_table_indexes(client, table, what="index", kind="definition")
|
|
1393
|
+
# Issue #312: an index remove_index(tx=…) removed in this transaction still stands in committed state; it is
|
|
1394
|
+
# missing once the transaction commits, so it is planned as missing (DEFINE INDEX after the removal).
|
|
1395
|
+
removed = tx._indexes_removed(table) if isinstance(tx, Transaction) else frozenset()
|
|
1396
|
+
if removed:
|
|
1397
|
+
stored_indexes = {name: state for name, state in stored_indexes.items() if name not in removed}
|
|
1380
1398
|
redefined = {analyzer.name for analyzer in redefine}
|
|
1381
1399
|
definitions, rebuilds = plan_indexes(
|
|
1382
1400
|
indexes,
|
|
@@ -1414,6 +1432,8 @@ class BaseSurrealModel(BaseModel):
|
|
|
1414
1432
|
classify=True,
|
|
1415
1433
|
subjects=[index_subject(name, table) for name, _ in definitions],
|
|
1416
1434
|
)
|
|
1435
|
+
if removed and isinstance(tx, Transaction):
|
|
1436
|
+
tx._forget_index_removals(table, (name for name, _ in definitions))
|
|
1417
1437
|
applied += await apply_rebuilds(client, tx, own_rebuilds)
|
|
1418
1438
|
warn_redefined(redefine, [*other_rebuilds, *redefined_indexes, *own_rebuilds])
|
|
1419
1439
|
return applied
|
|
@@ -1429,11 +1449,18 @@ class BaseSurrealModel(BaseModel):
|
|
|
1429
1449
|
not starting with a digit), checked before any request. The model's cached reads are dropped. A ``search()`` of
|
|
1430
1450
|
the field afterwards raises ``SurrealDbError`` until an index covers it again.
|
|
1431
1451
|
|
|
1452
|
+
With *tx*, the transaction notes the removal: :meth:`define_indexes` called later with the same *tx* counts the
|
|
1453
|
+
index as missing, although committed state still holds it, and defines it again after the removal when its
|
|
1454
|
+
model declares it — so removing an index and defining it again in one block keeps it. On SurrealDB 2.x, on a
|
|
1455
|
+
table that held records, such a block fails the commit with a retryable ``SurrealDbConflictError`` that a retry
|
|
1456
|
+
meets again, and nothing of it is committed. A raw ``tx.add("REMOVE INDEX …")`` is not noted.
|
|
1457
|
+
|
|
1432
1458
|
Args:
|
|
1433
1459
|
name: the index's name.
|
|
1434
1460
|
missing_ok: ``True`` (default) emits ``REMOVE INDEX IF EXISTS …``, so a missing index is not an error;
|
|
1435
1461
|
``False`` raises ``SurrealDbNotFoundError`` for it.
|
|
1436
|
-
tx: optional transaction the statement is applied with
|
|
1462
|
+
tx: optional transaction the statement is applied with; it notes the removal for
|
|
1463
|
+
:meth:`define_indexes`.
|
|
1437
1464
|
|
|
1438
1465
|
Raises:
|
|
1439
1466
|
TypeError, ValueError: *name* is not an identifier, or *missing_ok* not a ``bool`` — before any request.
|
|
@@ -1462,6 +1489,9 @@ class BaseSurrealModel(BaseModel):
|
|
|
1462
1489
|
classify=True,
|
|
1463
1490
|
subjects=[index_subject(name, table)],
|
|
1464
1491
|
)
|
|
1492
|
+
if isinstance(tx, Transaction):
|
|
1493
|
+
# Issue #312: define_indexes(tx=…) reads committed state, where the index still stands.
|
|
1494
|
+
tx._note_index_removal(table, name)
|
|
1465
1495
|
return statement
|
|
1466
1496
|
|
|
1467
1497
|
# ==================== Materialized views (v0.32.0) ====================
|
|
@@ -30,6 +30,11 @@ Records written (issue #304): an ORM write of records that joins a transaction a
|
|
|
30
30
|
for the cache only. ``define_indexes(tx=…)`` reads them (``_records_written``): SurrealDB servers do not index the
|
|
31
31
|
records a transaction wrote before the index was defined. A raw ``tx.add()`` is not noted.
|
|
32
32
|
|
|
33
|
+
Indexes removed (issue #312): ``remove_index(tx=…)`` notes the index it removes, by table (``_note_index_removal``).
|
|
34
|
+
``define_indexes(tx=…)`` reads committed state, where that index still stands: it counts the indexes noted for its table
|
|
35
|
+
(``_indexes_removed``) as missing, plans them again, and forgets those it defines (``_forget_index_removals``). The
|
|
36
|
+
commit and the cancel keep the note, like the tables written. A raw ``tx.add("REMOVE INDEX …")`` is not noted.
|
|
37
|
+
|
|
33
38
|
Errors (issue #278): the errors a failed transaction raises give the server's reason and the failed statement's
|
|
34
39
|
position, without the server's excerpt of the statement; the server's own text stays reachable as their suppressed
|
|
35
40
|
``__context__``. A query the server or the embedded engine refuses at a buffered commit raises ``SurrealDbError`` on
|
|
@@ -232,6 +237,9 @@ class Transaction(ABC):
|
|
|
232
237
|
# until the transaction ends.
|
|
233
238
|
self._record_tables: set[str] = set()
|
|
234
239
|
self._record_all = False
|
|
240
|
+
# Issue #312: the indexes remove_index(tx=…) removed in this transaction, by table, until define_indexes(tx=…)
|
|
241
|
+
# defines them again; kept until the transaction ends.
|
|
242
|
+
self._removed_indexes: dict[str, set[str]] = {}
|
|
235
243
|
# Issue #268: the errors of the statements that failed in this transaction (interactive strategy).
|
|
236
244
|
self._failures: list[BaseException] = []
|
|
237
245
|
|
|
@@ -292,6 +300,27 @@ class Transaction(ABC):
|
|
|
292
300
|
every table. ``define_indexes(tx=…)`` reads it; a raw ``tx.add()`` is not counted."""
|
|
293
301
|
return None if self._record_all else frozenset(self._record_tables)
|
|
294
302
|
|
|
303
|
+
def _note_index_removal(self, table: str, name: str) -> None:
|
|
304
|
+
"""Note that the index *name* of *table* was removed in this transaction — issue #312.
|
|
305
|
+
|
|
306
|
+
``remove_index(tx=…)`` calls it once its ``REMOVE INDEX`` was applied (interactive) or queued (buffered).
|
|
307
|
+
``define_indexes(tx=…)``, which reads committed state where the index still stands, counts it as missing. Like
|
|
308
|
+
the tables written, the commit and the cancel keep it. A raw ``tx.add()`` is not noted.
|
|
309
|
+
"""
|
|
310
|
+
self._removed_indexes.setdefault(table, set()).add(name)
|
|
311
|
+
|
|
312
|
+
def _indexes_removed(self, table: str) -> frozenset[str]:
|
|
313
|
+
"""The indexes of *table* removed in this transaction and not defined again since (issue #312)."""
|
|
314
|
+
return frozenset(self._removed_indexes.get(table, ()))
|
|
315
|
+
|
|
316
|
+
def _forget_index_removals(self, table: str, names: Iterable[str]) -> None:
|
|
317
|
+
"""Forget the removal of the indexes *names* of *table*, which ``define_indexes(tx=…)`` defined again in this
|
|
318
|
+
transaction (issue #312): a later call compares them with committed state again, as any index the transaction
|
|
319
|
+
did not remove, instead of defining them once more. A name not noted is ignored."""
|
|
320
|
+
removed = self._removed_indexes.get(table)
|
|
321
|
+
if removed is not None:
|
|
322
|
+
removed.difference_update(names)
|
|
323
|
+
|
|
295
324
|
@property
|
|
296
325
|
@abstractmethod
|
|
297
326
|
def is_interactive(self) -> bool:
|
|
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
|
{surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/connection_config.py
RENAMED
|
File without changes
|
{surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/connection_manager.py
RENAMED
|
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
|
{surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/testing/__init__.py
RENAMED
|
File without changes
|
{surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/testing/database.py
RENAMED
|
File without changes
|
{surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.2}/src/surreal_orm_lite/testing/fixtures.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|