surreal-orm-lite 0.37.4__tar.gz → 0.37.6__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.37.4 → surreal_orm_lite-0.37.6}/CHANGELOG.md +70 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/PKG-INFO +17 -4
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/README.md +16 -3
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/pyproject.toml +1 -1
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/__init__.py +1 -1
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/connection_manager.py +13 -5
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/model_base.py +23 -4
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/query_set.py +10 -6
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/search.py +58 -22
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/transaction.py +46 -6
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/.gitignore +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/LICENSE +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/Makefile +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/_sdk.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/aggregations.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/auth.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/cache.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/changefeed.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/concurrency.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/connection_config.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/constants.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/decoding.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/define_parser.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/edge.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/embedded.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/encoding.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/enum.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/exceptions.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/functions.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/geo.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/hybrid.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/introspection.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/live.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/model_auth.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/model_ddl.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/model_generator.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/py.typed +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/q.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/routing.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/schema.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/schema_state.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/signals.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/subquery.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/surql_literal.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/testing/__init__.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/testing/database.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/testing/fixtures.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/time_travel.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/types.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/utils.py +0 -0
- {surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/vector.py +0 -0
|
@@ -5,6 +5,27 @@ 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.6] - 2026-10-27
|
|
9
|
+
|
|
10
|
+
Follow-up to the review of v0.37.0 (#340): `hybrid_search()`'s docstring words its cross-line guarantee as
|
|
11
|
+
README section 38 does, and an empty `text_query` is tested against a server. No new public API.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- **`hybrid_search()`'s docstring states the cross-line guarantee with its condition** (#343).
|
|
16
|
+
`help(QuerySet.hybrid_search)` said the records, scores and order are the same on every line;
|
|
17
|
+
it now says that the same two lists give the same records, scores and order on every line, and
|
|
18
|
+
that the lists themselves can differ (the HNSW search is approximate, the full-text list follows
|
|
19
|
+
the line's BM25 scores). The `dist` argument names the exact scan's ties at the `vector_limit`-th
|
|
20
|
+
place on SurrealDB 2.x and the embedded engine, which the ORM keeps by id since v0.37.4.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- A server test now covers an empty `text_query`: it matches nothing, so the vector list alone is
|
|
25
|
+
fused and every `_search_score` is `None`, with the HNSW index and with an exact scan, over
|
|
26
|
+
WebSocket and HTTP and on the embedded engine. Measured on SurrealDB 2.7.0 and 3.3.4; 3.1.5
|
|
27
|
+
behaves as 3.3.4.
|
|
28
|
+
|
|
8
29
|
## [0.37.4] - 2026-10-27
|
|
9
30
|
|
|
10
31
|
Follow-up to the review of v0.37.0 (#340): the exact scan (`dist=`) of `similar_to()` and
|
|
@@ -37,6 +58,55 @@ embedded engine. No new public API.
|
|
|
37
58
|
- `TestExactScanTiesE2E` now expects one answer on every engine. Measured on SurrealDB 2.7.0 and
|
|
38
59
|
3.3.4 over WebSocket and HTTP, and on the embedded engine; 3.1.5 behaves as 3.3.4.
|
|
39
60
|
|
|
61
|
+
## [0.37.5] - 2026-10-27
|
|
62
|
+
|
|
63
|
+
Follow-up to the review of v0.36.4 (#328): analyzer DDL in a transaction now counts the indexes
|
|
64
|
+
that `define_indexes(tx=…)` defined earlier in the same block. No new public API.
|
|
65
|
+
|
|
66
|
+
### Fixed
|
|
67
|
+
|
|
68
|
+
- **`remove_analyzer(tx=…)` refuses an analyzer that an index defined in the block uses**
|
|
69
|
+
(#329). On SurrealDB 2.x and the embedded engine, it found the indexes that use the analyzer by
|
|
70
|
+
reading committed state, where an index that `define_indexes(tx=…)` defined earlier in the
|
|
71
|
+
block does not stand yet. Such a block committed and left the index without its analyzer: every
|
|
72
|
+
later write to the table was then refused ("The analyzer '…' does not exist"). On SurrealDB 3.x
|
|
73
|
+
the server refused the removal itself, which failed the block. The removal is now refused before
|
|
74
|
+
any DDL, with the existing "in use by index …" message, on every engine and line, and the
|
|
75
|
+
refusal does not fail the block. The transaction's note costs no request.
|
|
76
|
+
- **`define_analyzer(…, overwrite=True, tx=…)` refuses a redefinition when an index defined in
|
|
77
|
+
the block uses the analyzer** (#329). The block committed without `REBUILD INDEX` on every
|
|
78
|
+
engine, so the index kept the tokens of the old definition and a search could miss records.
|
|
79
|
+
The redefinition is now refused as one with indexes to rebuild, with the existing message,
|
|
80
|
+
before any DDL. The v0.36.4 note "an index queued earlier in a buffered block is still not seen"
|
|
81
|
+
no longer holds for `define_indexes(tx=…)`: both orders are guarded, in interactive and
|
|
82
|
+
buffered blocks, over WebSocket, HTTP and the embedded engine.
|
|
83
|
+
- **The last change of an index name in the block wins** (#329). An index defined then removed in
|
|
84
|
+
the block (`remove_index(tx=…)`) no longer counts. One that the block defined again with
|
|
85
|
+
another analyzer counts for that analyzer only, so the analyzer it held in committed state can
|
|
86
|
+
be removed or redefined in the block. An index defined with `IF NOT EXISTS`
|
|
87
|
+
(`define_indexes(overwrite=False, tx=…)`) keeps the block's earlier definition (another model's
|
|
88
|
+
on the same table) and counts with the analyzer that one gave it. A refused
|
|
89
|
+
`define_indexes(tx=…)` notes nothing. A raw `tx.add("DEFINE INDEX …")` is not tracked.
|
|
90
|
+
|
|
91
|
+
### Notes
|
|
92
|
+
|
|
93
|
+
- **Behaviour table**: a new row for `define_indexes(tx=)` then `remove_index(tx=)` in one block,
|
|
94
|
+
the index not stored before the block. SurrealDB 3.x fails the commit with a retryable
|
|
95
|
+
`SurrealDbConflictError` whatever the table holds, and nothing is committed; 2.x and the
|
|
96
|
+
embedded engine commit it, the index absent afterwards. An index stored before the block,
|
|
97
|
+
redefined and then removed in it, fails the commit the same way on 2.x too when the table held
|
|
98
|
+
records, the index standing as before; the embedded engine commits it (README section 36,
|
|
99
|
+
Transactions). Measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded
|
|
100
|
+
engine, identical on 3.1.5.
|
|
101
|
+
- **Docs**: README section 36 (Transactions) and the docstrings of `define_indexes()`,
|
|
102
|
+
`remove_index()`, `define_analyzer()` and `remove_analyzer()` describe the guarded orders.
|
|
103
|
+
- **Tests**: 76 new tests in `tests/test_search.py`: 18 unit tests of the transaction's notes and
|
|
104
|
+
of the analyzer DDL against them, 57 end-to-end tests over WebSocket, HTTP and the embedded
|
|
105
|
+
engine, in interactive and buffered blocks, and one check of the new behaviour-table row and its
|
|
106
|
+
intro sentence.
|
|
107
|
+
- Server pins unchanged: tested against SurrealDB 3.3.4 and 2.7.0 and on the embedded engine,
|
|
108
|
+
plus 3.1.5 for backward compatibility.
|
|
109
|
+
|
|
40
110
|
## [0.37.2] - 2026-10-27
|
|
41
111
|
|
|
42
112
|
A model with a `primary_key` can have its access defined on SurrealDB 3.x. No new public API.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: surreal-orm-lite
|
|
3
|
-
Version: 0.37.
|
|
3
|
+
Version: 0.37.6
|
|
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
|
|
@@ -6141,13 +6141,25 @@ print(await NoteV2.objects().search(text="physics").count())
|
|
|
6141
6141
|
- Prefer `define_indexes()` outside the block: on SurrealDB 2.x, a write to a table that held records, after its index
|
|
6142
6142
|
in the same block, fails the commit with a retryable `SurrealDbConflictError` that a retry meets again; so does a
|
|
6143
6143
|
block that removes an index of a table that held records and defines it again, where the index stands as before.
|
|
6144
|
-
Nothing of such a block is committed. On an empty table both commit, as on 3.x.
|
|
6144
|
+
Nothing of such a block is committed. On an empty table both commit, as on 3.x. On SurrealDB 3.x, a block that
|
|
6145
|
+
defines an index and then removes it fails the commit the same way, whatever the table holds; 2.x and the embedded
|
|
6146
|
+
engine commit it when the index was not stored before the block. An index stored before the block, redefined by
|
|
6147
|
+
`define_indexes(tx=…)` and then removed, fails the commit the same way on 2.x too when the table held records, where
|
|
6148
|
+
the index stands as before; the embedded engine commits it.
|
|
6145
6149
|
- `remove_analyzer(tx=…)` (on SurrealDB 2.x and the embedded engine; 3.x checks in the transaction itself) and
|
|
6146
6150
|
`define_analyzer(tx=…)` read committed state to find the indexes that use the analyzer. An index `remove_index(tx=…)`
|
|
6147
6151
|
removed earlier in the block no longer counts, although committed state still holds it: once the block has removed the
|
|
6148
6152
|
last index that uses an analyzer, it can remove the analyzer, or redefine it without `REBUILD INDEX`, on every engine.
|
|
6149
6153
|
An index removed then defined again in the block, or removed with a raw `tx.add("REMOVE INDEX …")`, still counts
|
|
6150
|
-
there
|
|
6154
|
+
there.
|
|
6155
|
+
- An index `define_indexes(tx=…)` defined earlier in the block counts too, with the analyzer the block gave it, although
|
|
6156
|
+
committed state does not hold it yet, or holds it with another analyzer: `remove_analyzer(tx=…)` and
|
|
6157
|
+
`define_analyzer(tx=…)` of that analyzer raise `SurrealDbError` before any DDL, naming the index, on every engine —
|
|
6158
|
+
SurrealDB 3.x included, whose own refusal of the removal used to fail the block. The refusal does not fail the block.
|
|
6159
|
+
An index defined then removed in the block no longer counts, and one the block defined again with another analyzer
|
|
6160
|
+
counts for that analyzer only. An index defined with `IF NOT EXISTS` (`define_indexes(overwrite=False, tx=…)`) keeps the
|
|
6161
|
+
block's earlier definition, and counts with the analyzer that one gave it. A raw `tx.add("DEFINE INDEX …")` is not
|
|
6162
|
+
tracked.
|
|
6151
6163
|
- Once the block has removed or redefined an analyzer, an index that uses it can no longer be defined in the block,
|
|
6152
6164
|
whether the model declares the analyzer as an `Analyzer` or names it by `str`: `define_indexes(tx=…)` raises
|
|
6153
6165
|
`SurrealDbError` before any DDL. A removed analyzer counts as missing, although committed state still holds it — the
|
|
@@ -6828,7 +6840,7 @@ features introduced in SurrealDB 3.x. On 2.x the ORM degrades gracefully. Capabi
|
|
|
6828
6840
|
listed behave the same on both lines. The 2.x column was measured on 2.6.5 and holds unchanged
|
|
6829
6841
|
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
|
|
6830
6842
|
otherwise. The full suite and every divergence below were re-verified on both new versions.
|
|
6831
|
-
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. The row added in v0.37.4 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5.
|
|
6843
|
+
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. The row added in v0.37.4 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.37.5 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5.
|
|
6832
6844
|
The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded engine](#orm-behaviour-the-embedded-engine).
|
|
6833
6845
|
|
|
6834
6846
|
| ORM capability | SurrealDB 2.6.x / 2.7.x | SurrealDB 3.2.x / 3.3.x | Since |
|
|
@@ -6994,6 +7006,7 @@ The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded
|
|
|
6994
7006
|
| `hybrid_search()` with other conditions | applied to both lists; the vector list selects the records first (a `LET`), as `similar_to()` does | applied to both lists, during each search | v0.37.0 |
|
|
6995
7007
|
| `hybrid_search()` on a field without a vector or full-text index | no vector index: the vector list is empty, so the full-text ranking alone is fused; no full-text index: `SurrealDbError` naming the field | the same; 3.1 and 3.2 put the first `vector_limit` records by id in the vector list, with no distance, and match no record for the text | v0.37.0 |
|
|
6996
7008
|
| An exact scan (`similar_to(dist=…)`, `hybrid_search(dist=…)`) with records at an equal distance at the last place | the ORM ranks the scan by distance, then id: the same records on every call, the tied ones by id (2.x's own scan picks among them in no fixed order) | the same records on every call, as with the HNSW index | v0.37.4 |
|
|
7009
|
+
| `define_indexes(tx=)` then `remove_index(tx=)` in one block, the index not stored before the block | committed: the index absent after the commit, whatever the table holds | the commit fails with a retryable `SurrealDbConflictError`, whatever the table holds: nothing committed | v0.37.5 |
|
|
6997
7010
|
| 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 |
|
|
6998
7011
|
|
|
6999
7012
|
> **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.
|
|
@@ -6090,13 +6090,25 @@ print(await NoteV2.objects().search(text="physics").count())
|
|
|
6090
6090
|
- Prefer `define_indexes()` outside the block: on SurrealDB 2.x, a write to a table that held records, after its index
|
|
6091
6091
|
in the same block, fails the commit with a retryable `SurrealDbConflictError` that a retry meets again; so does a
|
|
6092
6092
|
block that removes an index of a table that held records and defines it again, where the index stands as before.
|
|
6093
|
-
Nothing of such a block is committed. On an empty table both commit, as on 3.x.
|
|
6093
|
+
Nothing of such a block is committed. On an empty table both commit, as on 3.x. On SurrealDB 3.x, a block that
|
|
6094
|
+
defines an index and then removes it fails the commit the same way, whatever the table holds; 2.x and the embedded
|
|
6095
|
+
engine commit it when the index was not stored before the block. An index stored before the block, redefined by
|
|
6096
|
+
`define_indexes(tx=…)` and then removed, fails the commit the same way on 2.x too when the table held records, where
|
|
6097
|
+
the index stands as before; the embedded engine commits it.
|
|
6094
6098
|
- `remove_analyzer(tx=…)` (on SurrealDB 2.x and the embedded engine; 3.x checks in the transaction itself) and
|
|
6095
6099
|
`define_analyzer(tx=…)` read committed state to find the indexes that use the analyzer. An index `remove_index(tx=…)`
|
|
6096
6100
|
removed earlier in the block no longer counts, although committed state still holds it: once the block has removed the
|
|
6097
6101
|
last index that uses an analyzer, it can remove the analyzer, or redefine it without `REBUILD INDEX`, on every engine.
|
|
6098
6102
|
An index removed then defined again in the block, or removed with a raw `tx.add("REMOVE INDEX …")`, still counts
|
|
6099
|
-
there
|
|
6103
|
+
there.
|
|
6104
|
+
- An index `define_indexes(tx=…)` defined earlier in the block counts too, with the analyzer the block gave it, although
|
|
6105
|
+
committed state does not hold it yet, or holds it with another analyzer: `remove_analyzer(tx=…)` and
|
|
6106
|
+
`define_analyzer(tx=…)` of that analyzer raise `SurrealDbError` before any DDL, naming the index, on every engine —
|
|
6107
|
+
SurrealDB 3.x included, whose own refusal of the removal used to fail the block. The refusal does not fail the block.
|
|
6108
|
+
An index defined then removed in the block no longer counts, and one the block defined again with another analyzer
|
|
6109
|
+
counts for that analyzer only. An index defined with `IF NOT EXISTS` (`define_indexes(overwrite=False, tx=…)`) keeps the
|
|
6110
|
+
block's earlier definition, and counts with the analyzer that one gave it. A raw `tx.add("DEFINE INDEX …")` is not
|
|
6111
|
+
tracked.
|
|
6100
6112
|
- Once the block has removed or redefined an analyzer, an index that uses it can no longer be defined in the block,
|
|
6101
6113
|
whether the model declares the analyzer as an `Analyzer` or names it by `str`: `define_indexes(tx=…)` raises
|
|
6102
6114
|
`SurrealDbError` before any DDL. A removed analyzer counts as missing, although committed state still holds it — the
|
|
@@ -6777,7 +6789,7 @@ features introduced in SurrealDB 3.x. On 2.x the ORM degrades gracefully. Capabi
|
|
|
6777
6789
|
listed behave the same on both lines. The 2.x column was measured on 2.6.5 and holds unchanged
|
|
6778
6790
|
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
|
|
6779
6791
|
otherwise. The full suite and every divergence below were re-verified on both new versions.
|
|
6780
|
-
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. The row added in v0.37.4 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5.
|
|
6792
|
+
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. The row added in v0.37.4 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.37.5 was measured on 2.7.0 and 3.3.4, over WebSocket and HTTP, and on the embedded engine, identical on 3.1.5.
|
|
6781
6793
|
The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded engine](#orm-behaviour-the-embedded-engine).
|
|
6782
6794
|
|
|
6783
6795
|
| ORM capability | SurrealDB 2.6.x / 2.7.x | SurrealDB 3.2.x / 3.3.x | Since |
|
|
@@ -6943,6 +6955,7 @@ The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded
|
|
|
6943
6955
|
| `hybrid_search()` with other conditions | applied to both lists; the vector list selects the records first (a `LET`), as `similar_to()` does | applied to both lists, during each search | v0.37.0 |
|
|
6944
6956
|
| `hybrid_search()` on a field without a vector or full-text index | no vector index: the vector list is empty, so the full-text ranking alone is fused; no full-text index: `SurrealDbError` naming the field | the same; 3.1 and 3.2 put the first `vector_limit` records by id in the vector list, with no distance, and match no record for the text | v0.37.0 |
|
|
6945
6957
|
| An exact scan (`similar_to(dist=…)`, `hybrid_search(dist=…)`) with records at an equal distance at the last place | the ORM ranks the scan by distance, then id: the same records on every call, the tied ones by id (2.x's own scan picks among them in no fixed order) | the same records on every call, as with the HNSW index | v0.37.4 |
|
|
6958
|
+
| `define_indexes(tx=)` then `remove_index(tx=)` in one block, the index not stored before the block | committed: the index absent after the commit, whatever the table holds | the commit fails with a retryable `SurrealDbConflictError`, whatever the table holds: nothing committed | v0.37.5 |
|
|
6946
6959
|
| 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 |
|
|
6947
6960
|
|
|
6948
6961
|
> **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.
|
{surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/connection_manager.py
RENAMED
|
@@ -2750,9 +2750,13 @@ class SurrealDBConnectionManager:
|
|
|
2750
2750
|
removed earlier with the same *tx* is not to rebuild, although committed state still holds it: once the block
|
|
2751
2751
|
has removed every index that uses the analyzer, the redefinition joins the transaction, without
|
|
2752
2752
|
``REBUILD INDEX``. An index removed then defined again in the block (``define_indexes(tx=…)``), or removed with
|
|
2753
|
-
a raw ``tx.add("REMOVE INDEX …")``, which the transaction does not track, still counts.
|
|
2754
|
-
|
|
2755
|
-
|
|
2753
|
+
a raw ``tx.add("REMOVE INDEX …")``, which the transaction does not track, still counts. An index
|
|
2754
|
+
``Model.define_indexes()`` defined earlier with the same *tx* counts with the analyzer the block gave it,
|
|
2755
|
+
although committed state does not hold it yet, or holds it with another analyzer (issue #329): the redefinition
|
|
2756
|
+
of that analyzer is refused before any DDL, and the refusal does not fail the block; an index defined then
|
|
2757
|
+
removed in the block no longer counts. The transaction notes the analyzer it defines or redefines:
|
|
2758
|
+
``Model.define_indexes(tx=…)`` then refuses, before any DDL, to define in the block an index that uses it —
|
|
2759
|
+
SurrealDB would build it with the committed definition. An analyzer
|
|
2756
2760
|
:meth:`remove_analyzer` removed earlier with the same *tx* counts as missing, although committed state still
|
|
2757
2761
|
holds it: it is defined again after its removal.
|
|
2758
2762
|
|
|
@@ -2802,8 +2806,12 @@ class SurrealDBConnectionManager:
|
|
|
2802
2806
|
removed earlier with the same *tx* is left out, although committed state still holds it, so a block that
|
|
2803
2807
|
removes the last index using the analyzer and then the analyzer commits, as on SurrealDB 3.x, which checks in
|
|
2804
2808
|
the transaction; an index removed then defined again in the block, or removed with a raw
|
|
2805
|
-
``tx.add("REMOVE INDEX …")``, which the transaction does not track, still counts
|
|
2806
|
-
|
|
2809
|
+
``tx.add("REMOVE INDEX …")``, which the transaction does not track, still counts. On every line, SurrealDB 3.x
|
|
2810
|
+
included, an index ``Model.define_indexes()`` defined earlier with the same *tx* counts with the analyzer the
|
|
2811
|
+
block gave it, although committed state does not hold it yet, or holds it with another analyzer (issue #329):
|
|
2812
|
+
the removal of that analyzer is refused before any DDL — the transaction's note costs no request — and the
|
|
2813
|
+
refusal does not fail the block (on 3.x, the server's own refusal used to); an index defined then removed in the
|
|
2814
|
+
block no longer counts. The transaction notes the removal: ``Model.define_indexes(tx=…)`` then counts the
|
|
2807
2815
|
analyzer as missing, although committed state still holds it, and refuses, before any DDL, to define in the
|
|
2808
2816
|
block an index that uses it — the commit would leave that index without its analyzer, and every write to its
|
|
2809
2817
|
table refused; :meth:`define_analyzer` with the same *tx* defines it again. No cached read is dropped: a
|
|
@@ -1523,6 +1523,15 @@ class BaseSurrealModel(BaseModel):
|
|
|
1523
1523
|
``define_analyzer()`` redefined with the same *tx* is refused too, whether the model declares it or names it:
|
|
1524
1524
|
SurrealDB would build it with the committed definition. Call ``define_analyzer()`` without *tx* first.
|
|
1525
1525
|
|
|
1526
|
+
**The indexes defined in the transaction** (issue #329). With *tx*, the transaction notes each index this call
|
|
1527
|
+
defines or redefines, with its analyzer, once the statements are applied or queued — nothing when the call
|
|
1528
|
+
refuses or a statement is refused at once. ``remove_analyzer()`` and ``define_analyzer()`` with the same *tx*
|
|
1529
|
+
count those indexes, although committed state does not hold them yet (or holds them with another analyzer):
|
|
1530
|
+
removing or redefining their analyzer later in the block is refused before any DDL, on every engine. An index
|
|
1531
|
+
:meth:`remove_index` then removes with the same *tx* no longer counts. Without *overwrite*, an index defined
|
|
1532
|
+
with ``IF NOT EXISTS`` keeps the block's earlier definition — another model's on the same table, with another
|
|
1533
|
+
analyzer — and so does the note: that index counts with the analyzer the block gave it first.
|
|
1534
|
+
|
|
1526
1535
|
Names are written in backticks, filters re-rendered from a closed grammar, numbers from Python numbers,
|
|
1527
1536
|
comments as string literals. A refusal names the analyzer or the index and its table, never the statement:
|
|
1528
1537
|
``Can't apply index definition: 'post_title' on table 'post' -> <reason>``. Applying needs a session allowed to
|
|
@@ -1534,7 +1543,8 @@ class BaseSurrealModel(BaseModel):
|
|
|
1534
1543
|
what is missing (``IF NOT EXISTS``) and leaves what exists as it is.
|
|
1535
1544
|
tx: optional transaction the index statements are applied with; the reads happen before anything is
|
|
1536
1545
|
queued. An index :meth:`remove_index` removed with it counts as missing, and so does an analyzer
|
|
1537
|
-
``remove_analyzer()`` removed with it.
|
|
1546
|
+
``remove_analyzer()`` removed with it. It notes the indexes defined, for ``remove_analyzer()`` and
|
|
1547
|
+
``define_analyzer()``.
|
|
1538
1548
|
|
|
1539
1549
|
Raises:
|
|
1540
1550
|
TypeError: *overwrite* is not a ``bool`` — before any request.
|
|
@@ -1633,8 +1643,13 @@ class BaseSurrealModel(BaseModel):
|
|
|
1633
1643
|
classify=True,
|
|
1634
1644
|
subjects=[index_subject(name, table) for name, _ in definitions],
|
|
1635
1645
|
)
|
|
1636
|
-
if
|
|
1637
|
-
|
|
1646
|
+
if isinstance(tx, Transaction):
|
|
1647
|
+
# Noted once applied or queued: every refusal above notes nothing. Issue #312: an index defined again is no
|
|
1648
|
+
# longer missing (its removal is forgotten). Issue #329: remove_analyzer(tx=…) and define_analyzer(tx=…)
|
|
1649
|
+
# read committed state, which does not hold these definitions yet, or holds them with another analyzer.
|
|
1650
|
+
# Without overwrite, each is a DEFINE INDEX IF NOT EXISTS: one this block defined earlier stays as it was.
|
|
1651
|
+
for name, _ in definitions:
|
|
1652
|
+
tx._note_index_definition(table, name, analyzer_of[name], if_not_exists=not overwrite)
|
|
1638
1653
|
applied += await apply_rebuilds(client, tx, own_rebuilds)
|
|
1639
1654
|
warn_redefined(redefine, [*other_rebuilds, *redefined_indexes, *own_rebuilds])
|
|
1640
1655
|
return applied
|
|
@@ -1654,7 +1669,11 @@ class BaseSurrealModel(BaseModel):
|
|
|
1654
1669
|
index as missing, although committed state still holds it, and defines it again after the removal when its
|
|
1655
1670
|
model declares it — so removing an index and defining it again in one block keeps it. On SurrealDB 2.x, on a
|
|
1656
1671
|
table that held records, such a block fails the commit with a retryable ``SurrealDbConflictError`` that a retry
|
|
1657
|
-
meets again, and nothing of it is committed.
|
|
1672
|
+
meets again, and nothing of it is committed. On SurrealDB 3.x, the reverse — a block that defines an index
|
|
1673
|
+
(:meth:`define_indexes`) and then removes it — fails the commit the same way, whatever the table holds; 2.x and
|
|
1674
|
+
the embedded engine commit it when the index was not stored before the block. When it was, and the block
|
|
1675
|
+
redefined it before removing it, 2.x fails the commit the same way on a table that held records, the index
|
|
1676
|
+
standing as before, and the embedded engine commits it. ``SurrealDBConnectionManager.remove_analyzer(tx=…)`` and
|
|
1658
1677
|
``define_analyzer(tx=…)`` read the note too: the removed index no longer counts as one using the analyzer (issue
|
|
1659
1678
|
#323); once the block has removed or redefined that analyzer, :meth:`define_indexes` refuses to define the index
|
|
1660
1679
|
again in it. A raw ``tx.add("REMOVE INDEX …")`` is not noted.
|
|
@@ -2159,14 +2159,15 @@ class QuerySet:
|
|
|
2159
2159
|
counted from 1, and the records come back best first; equal scores keep the vector list's order first, then
|
|
2160
2160
|
the full-text list's for the records it alone found. SurrealDB 3.x fuses the lists with its ``search::rrf()``;
|
|
2161
2161
|
SurrealDB 2.x and the embedded engine have no such function, so the ORM fuses them with the same formula: the
|
|
2162
|
-
records, scores and order
|
|
2163
|
-
|
|
2162
|
+
same two lists give the same records, scores and order on every line. Each list is SurrealDB's own, so the
|
|
2163
|
+
lists themselves can differ between lines: the HNSW search is approximate, and the full-text list follows the
|
|
2164
|
+
line's BM25 scores (a term found in more than half the documents scores ``0.0`` on SurrealDB 3.x and below
|
|
2165
|
+
zero on 2.x and the embedded engine, README section 36). The vector and the text are bound as query
|
|
2166
|
+
variables, never written into the statement.
|
|
2164
2167
|
|
|
2165
2168
|
Each record is a dict — the full SurrealDB-ORM's result: its fields keyed by their Python names and
|
|
2166
2169
|
``_rrf_score``, plus ``_knn_distance`` (its distance, ``None`` when only the full-text search found it) and
|
|
2167
|
-
``_search_score`` (its BM25 score, ``None`` when only the vector search found it).
|
|
2168
|
-
gives identical calls one vector list on every line: records at an equal distance at the ``vector_limit``-th
|
|
2169
|
-
place are kept by id on SurrealDB 2.x and the embedded engine, as ``similar_to(dist=...)`` keeps them.
|
|
2170
|
+
``_search_score`` (its BM25 score, ``None`` when only the vector search found it).
|
|
2170
2171
|
|
|
2171
2172
|
Each search needs its index. Without a full-text index on ``text_field``, SurrealDB 3.3, 2.x and the embedded
|
|
2172
2173
|
engine refuse the search (``SurrealDbError`` naming the field), while SurrealDB 3.1 and 3.2 match nothing.
|
|
@@ -2197,7 +2198,10 @@ class QuerySet:
|
|
|
2197
2198
|
ef: The HNSW search's candidate list: ``None`` (100) or an ``int`` from 1 to 10000, raised to
|
|
2198
2199
|
``vector_limit``.
|
|
2199
2200
|
dist: An exact scan by this distance instead of the index's search: ``EUCLIDEAN``, ``COSINE``,
|
|
2200
|
-
``MANHATTAN``, ``CHEBYSHEV`` or ``HAMMING``, in any case; not with ``ef``.
|
|
2201
|
+
``MANHATTAN``, ``CHEBYSHEV`` or ``HAMMING``, in any case; not with ``ef``. SurrealDB 2.x's and the
|
|
2202
|
+
embedded engine's own scan picks among records at an equal distance at the ``vector_limit``-th place
|
|
2203
|
+
in no fixed order, so there the ORM ranks it by distance, then id, as ``similar_to(dist=...)`` does:
|
|
2204
|
+
the tied records are kept by id, and identical calls get one vector list on every line.
|
|
2201
2205
|
|
|
2202
2206
|
Returns:
|
|
2203
2207
|
list[dict[str, Any]]: The fused records, best first, each a dict of its fields and ``_rrf_score``,
|
|
@@ -60,10 +60,12 @@ warning per redefined analyzer. ``apply_analyzer()`` and ``apply_analyzer_remova
|
|
|
60
60
|
manager's ``define_analyzer()`` and ``remove_analyzer()``; the latter refuses, below SurrealDB 3 (2.x, the embedded
|
|
61
61
|
engine, which would remove it and then refuse every write to the table), an analyzer an index uses, with 3.x's own
|
|
62
62
|
reason. With a transaction, both leave out the indexes ``remove_index(tx=…)`` removed earlier in it, which committed
|
|
63
|
-
state still holds (``indexes_removed_in()``, the transaction's note — issue #323),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
state still holds (``indexes_removed_in()``, the transaction's note — issue #323), count those ``define_indexes(tx=…)``
|
|
64
|
+
defined earlier in it with the analyzer it gave them, which committed state does not hold yet
|
|
65
|
+
(``indexes_using_once_committed()``, issue #329; ``remove_analyzer(tx=…)`` on every line), and note the analyzer they
|
|
66
|
+
removed or defined (``note_analyzer_change()``): ``define_analyzer(tx=…)`` and ``define_indexes(tx=…)`` count one the
|
|
67
|
+
block removed as missing (``analyzers_after_removals()``), and ``define_indexes(tx=…)`` refuses an index whose analyzer
|
|
68
|
+
the block redefined (``transaction_redefined_analyzer_refused()``).
|
|
67
69
|
|
|
68
70
|
**The query side.** ``QuerySet.search()`` checks its fields and texts with ``checked_search_field()`` and words its
|
|
69
71
|
refusals with ``text_refused()``, ``field_refused()``, ``too_many_fields()``, ``time_travel_refused()`` (with
|
|
@@ -77,8 +79,8 @@ annotation whose match reference ``search()`` did not give it is refused with ``
|
|
|
77
79
|
``search()`` with ``no_search_refused()``.
|
|
78
80
|
|
|
79
81
|
The module sits low in the package: it imports neither ``model_base``, ``query_set`` nor ``connection_manager``, so
|
|
80
|
-
each of them can import it; it imports ``transaction``, which imports none of them, for its
|
|
81
|
-
|
|
82
|
+
each of them can import it; it imports ``transaction``, which imports none of them, for its notes of the indexes
|
|
83
|
+
removed and defined.
|
|
82
84
|
"""
|
|
83
85
|
|
|
84
86
|
import logging
|
|
@@ -1170,7 +1172,9 @@ async def indexes_using(
|
|
|
1170
1172
|
the parser cannot read is left out (its analyzer is unknown), and so is one *skip* names for its table: *skip*
|
|
1171
1173
|
takes a table's name, as ``INFO FOR DB`` gives it, and returns the names of its indexes to leave out —
|
|
1172
1174
|
:func:`indexes_removed_in`'s, the indexes ``remove_index(tx=…)`` removed earlier in a transaction, which committed
|
|
1173
|
-
state still holds (issue #323). Every table is read all the same.
|
|
1175
|
+
state still holds (issue #323). Every table is read all the same. An index ``define_indexes(tx=…)`` defined earlier
|
|
1176
|
+
in a transaction is not here, or with the committed analyzer: :func:`indexes_using_once_committed` gives the indexes
|
|
1177
|
+
once the transaction commits (issue #329).
|
|
1174
1178
|
|
|
1175
1179
|
:param what: what the reads are for, for the message of a refusal (``"index"``, ``"analyzer"``).
|
|
1176
1180
|
:param kind: ``"definition"``, ``"removal"`` or ``"rebuild"``, likewise.
|
|
@@ -1192,6 +1196,29 @@ def indexes_removed_in(tx: object) -> Callable[[str], frozenset[str]] | None:
|
|
|
1192
1196
|
return tx._indexes_removed if isinstance(tx, Transaction) else None
|
|
1193
1197
|
|
|
1194
1198
|
|
|
1199
|
+
def indexes_using_once_committed(found: Iterable[IndexUse], analyzers: Collection[str], tx: object) -> list[IndexUse]:
|
|
1200
|
+
"""The indexes that use one of *analyzers* once *tx* commits, as ``(table, index, analyzer)``, sorted by table then
|
|
1201
|
+
index — pure (issue #329).
|
|
1202
|
+
|
|
1203
|
+
*found* is committed state: :func:`indexes_using`'s answer for *analyzers*, the indexes ``remove_index(tx=…)``
|
|
1204
|
+
removed in *tx* already left out (:func:`indexes_removed_in`), or ``[]`` when committed state was not read. An index
|
|
1205
|
+
``define_indexes(tx=…)`` defined in *tx* and did not remove since (``Transaction._indexes_defined``) replaces the
|
|
1206
|
+
committed one of its name on its table — the analyzer the block gave it wins — and counts when that analyzer is
|
|
1207
|
+
among *analyzers*: committed state does not hold it yet. *found*, sorted, when *tx* is not a ``Transaction``.
|
|
1208
|
+
"""
|
|
1209
|
+
if not isinstance(tx, Transaction):
|
|
1210
|
+
return sorted(found)
|
|
1211
|
+
defined = tx._indexes_defined()
|
|
1212
|
+
kept = [use for use in found if use[1] not in defined.get(use[0], {})]
|
|
1213
|
+
kept.extend(
|
|
1214
|
+
(table, name, analyzer)
|
|
1215
|
+
for table, indexes in defined.items()
|
|
1216
|
+
for name, analyzer in indexes.items()
|
|
1217
|
+
if analyzer and analyzer in analyzers
|
|
1218
|
+
)
|
|
1219
|
+
return sorted(kept)
|
|
1220
|
+
|
|
1221
|
+
|
|
1195
1222
|
def analyzers_after_removals(stored: Mapping[str, AnalyzerState | None], tx: object) -> dict[str, AnalyzerState | None]:
|
|
1196
1223
|
"""The analyzers *stored* holds (``INFO FOR DB``'s, committed state) without those ``remove_analyzer(tx=…)``
|
|
1197
1224
|
removed earlier in *tx* and did not define again since — *tx*'s ``Transaction._analyzers_removed`` (issue #323):
|
|
@@ -1449,9 +1476,12 @@ async def apply_analyzer(client: Any, analyzer: Analyzer, *, overwrite: bool, tx
|
|
|
1449
1476
|
follow the committed definition); a new analyzer, or a redefinition no index uses, joins the transaction. An index
|
|
1450
1477
|
``remove_index(tx=…)`` removed earlier in *tx* is not to rebuild, although committed state still holds it
|
|
1451
1478
|
(:func:`indexes_removed_in`, issue #323): a redefinition whose indexes the block all removed joins the transaction,
|
|
1452
|
-
without ``REBUILD INDEX``. An
|
|
1453
|
-
|
|
1454
|
-
|
|
1479
|
+
without ``REBUILD INDEX``. An index ``define_indexes(tx=…)`` defined earlier in *tx* counts with the analyzer the
|
|
1480
|
+
block gave it, although committed state does not hold it yet or holds it with another analyzer
|
|
1481
|
+
(:func:`indexes_using_once_committed`, issue #329): a redefinition of that analyzer is refused, and one of the
|
|
1482
|
+
analyzer it held before no longer rebuilds it. An analyzer ``remove_analyzer(tx=…)`` removed earlier in *tx* counts
|
|
1483
|
+
as missing (:func:`analyzers_after_removals`): defined again after its removal, with no index read nor rebuilt. *tx*
|
|
1484
|
+
notes the analyzer once defined or redefined (:func:`note_analyzer_change`), for ``define_indexes(tx=…)``.
|
|
1455
1485
|
|
|
1456
1486
|
:raises SurrealDbError: *tx* is given and the redefinition has indexes to rebuild; a refused read or statement.
|
|
1457
1487
|
:raises SurrealDbAuthenticationError: the session may not read the definitions or define the analyzer.
|
|
@@ -1461,9 +1491,10 @@ async def apply_analyzer(client: Any, analyzer: Analyzer, *, overwrite: bool, tx
|
|
|
1461
1491
|
define, redefine = plan_analyzers([analyzer], analyzers_after_removals(stored, tx), overwrite)
|
|
1462
1492
|
rebuilds: list[IndexUse] = []
|
|
1463
1493
|
if redefine:
|
|
1464
|
-
|
|
1494
|
+
found = await indexes_using(
|
|
1465
1495
|
client, tables, {analyzer.name}, what="analyzer", kind="definition", skip=indexes_removed_in(tx)
|
|
1466
1496
|
)
|
|
1497
|
+
rebuilds = indexes_using_once_committed(found, {analyzer.name}, tx)
|
|
1467
1498
|
if tx is not None and rebuilds:
|
|
1468
1499
|
raise SurrealDbError(analyzer_redefinition_refused(analyzer.name, rebuilds))
|
|
1469
1500
|
applied = await apply_analyzers(client, tx, define, redefine, overwrite)
|
|
@@ -1480,25 +1511,30 @@ async def apply_analyzer_removal(client: Any, name: str, statement: str, *, tx:
|
|
|
1480
1511
|
|
|
1481
1512
|
``client.version()`` once. Below 3 (SurrealDB 2.x, the embedded engine), which accept the removal of an analyzer an
|
|
1482
1513
|
index uses and then refuse every write to that table: ``INFO FOR DB``, then ``INFO FOR TABLE`` of every table
|
|
1483
|
-
(:func:`indexes_using`, committed state)
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1514
|
+
(:func:`indexes_using`, committed state). An index ``remove_index(tx=…)`` removed earlier in *tx* is left out,
|
|
1515
|
+
although committed state still holds it (:func:`indexes_removed_in`, issue #323). On every line, an index
|
|
1516
|
+
``define_indexes(tx=…)`` defined earlier in *tx* counts with the analyzer the block gave it, which committed state
|
|
1517
|
+
does not hold yet (:func:`indexes_using_once_committed`, issue #329) — the note costs no request: from 3 on, where
|
|
1518
|
+
the server checks committed state itself, the line is the only read. The first index using the analyzer, in table
|
|
1519
|
+
then index order, is refused with SurrealDB 3.x's own reason, before any DDL; the refusal does not fail *tx*. From 3
|
|
1520
|
+
on, the server refuses any other in the same words, in the transaction. Then the statement, joining *tx* when given:
|
|
1521
|
+
``Can't apply analyzer removal: '<name>' -> <reason>`` for a refusal. *tx* notes the removal once applied or queued
|
|
1522
|
+
(:func:`note_analyzer_change`): ``define_analyzer(tx=…)`` and ``define_indexes(tx=…)`` then count the analyzer as
|
|
1523
|
+
missing (issue #323).
|
|
1490
1524
|
|
|
1491
1525
|
:raises SurrealDbError: an index uses the analyzer; a refused read or statement.
|
|
1492
1526
|
:raises SurrealDbNotFoundError: ``REMOVE ANALYZER`` without ``IF EXISTS`` of a missing analyzer (outside a buffered
|
|
1493
1527
|
transaction).
|
|
1494
1528
|
:raises SurrealDbAuthenticationError: the session may not read the definitions or remove the analyzer.
|
|
1495
1529
|
"""
|
|
1530
|
+
found: list[IndexUse] = []
|
|
1496
1531
|
if line_major(await client.version()) < 3:
|
|
1497
1532
|
_, tables = await read_database_info(client, what="analyzer", kind="removal", subject=repr(name))
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1533
|
+
found = await indexes_using(client, tables, {name}, what="analyzer", kind="removal", skip=indexes_removed_in(tx))
|
|
1534
|
+
using = indexes_using_once_committed(found, {name}, tx)
|
|
1535
|
+
if using:
|
|
1536
|
+
table, index, _ = using[0]
|
|
1537
|
+
raise SurrealDbError(analyzer_in_use_refused(name, index, table))
|
|
1502
1538
|
await apply_ddl_statements(
|
|
1503
1539
|
[statement], client=client, tx=tx, what="analyzer", kind="removal", classify=True, subjects=[repr(name)]
|
|
1504
1540
|
)
|
|
@@ -32,10 +32,20 @@ records a transaction wrote before the index was defined. A raw ``tx.add()`` is
|
|
|
32
32
|
|
|
33
33
|
Indexes removed (issue #312): ``remove_index(tx=…)`` notes the index it removes, by table (``_note_index_removal``).
|
|
34
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
|
|
36
|
-
``remove_analyzer(tx=…)`` and ``define_analyzer(tx=…)`` read committed state too, and
|
|
37
|
-
those that use the analyzer (issue #323). The commit and the cancel keep the note, like
|
|
38
|
-
``tx.add("REMOVE INDEX …")`` is not noted.
|
|
35
|
+
(``_indexes_removed``) as missing, plans them again, and forgets those it defines (``_forget_index_removals``, through
|
|
36
|
+
``_note_index_definition``). ``remove_analyzer(tx=…)`` and ``define_analyzer(tx=…)`` read committed state too, and
|
|
37
|
+
leave the noted indexes out of those that use the analyzer (issue #323). The commit and the cancel keep the note, like
|
|
38
|
+
the tables written. A raw ``tx.add("REMOVE INDEX …")`` is not noted.
|
|
39
|
+
|
|
40
|
+
Indexes defined (issue #329): ``define_indexes(tx=…)`` notes each index it defines or redefines, by table, with its
|
|
41
|
+
analyzer (``_note_index_definition``, ``""`` for none), once the statements are applied or queued — a refusal notes
|
|
42
|
+
nothing. ``remove_analyzer(tx=…)`` and ``define_analyzer(tx=…)`` count them among the indexes that use their analyzer
|
|
43
|
+
(``_indexes_defined``), although committed state does not hold them yet, or holds them with another analyzer. The last
|
|
44
|
+
change of an index name wins: a definition forgets the removal noted for that name and replaces an earlier definition;
|
|
45
|
+
a removal drops the definition. A ``DEFINE INDEX IF NOT EXISTS`` (``define_indexes(overwrite=False, tx=…)``) is the
|
|
46
|
+
exception: it leaves an index the block defined earlier as it is, and the note keeps that definition. The commit and
|
|
47
|
+
the cancel keep the note; a statement a buffered commit refuses leaves it as noted, like the other notes. A raw
|
|
48
|
+
``tx.add("DEFINE INDEX …")`` is not noted.
|
|
39
49
|
|
|
40
50
|
Analyzers changed (issue #323): ``remove_analyzer(tx=…)`` notes the analyzer it removes (``_note_analyzer_removal``),
|
|
41
51
|
``define_analyzer(tx=…)`` the one it defines or redefines (``_note_analyzer_definition``); the last change of a name
|
|
@@ -248,6 +258,9 @@ class Transaction(ABC):
|
|
|
248
258
|
# Issue #312: the indexes remove_index(tx=…) removed in this transaction, by table, until define_indexes(tx=…)
|
|
249
259
|
# defines them again; kept until the transaction ends.
|
|
250
260
|
self._removed_indexes: dict[str, set[str]] = {}
|
|
261
|
+
# Issue #329: the indexes define_indexes(tx=…) defined in this transaction, by table, each with its analyzer
|
|
262
|
+
# ("" for none) — the last change of an index name wins; kept until the transaction ends.
|
|
263
|
+
self._defined_indexes: dict[str, dict[str, str]] = {}
|
|
251
264
|
# Issue #323: the analyzers remove_analyzer(tx=…) removed and those define_analyzer(tx=…) defined or redefined
|
|
252
265
|
# in this transaction — the last change of a name wins; kept until the transaction ends.
|
|
253
266
|
self._removed_analyzers: set[str] = set()
|
|
@@ -319,9 +332,12 @@ class Transaction(ABC):
|
|
|
319
332
|
``remove_index(tx=…)`` calls it once its ``REMOVE INDEX`` was applied (interactive) or queued (buffered).
|
|
320
333
|
``define_indexes(tx=…)``, which reads committed state where the index still stands, counts it as missing;
|
|
321
334
|
``remove_analyzer(tx=…)`` and ``define_analyzer(tx=…)`` no longer count it among the indexes that use an
|
|
322
|
-
analyzer (issue #323).
|
|
323
|
-
noted.
|
|
335
|
+
analyzer (issue #323). A definition noted before for the same name on *table* is forgotten (issue #329). Like
|
|
336
|
+
the tables written, the commit and the cancel keep it. A raw ``tx.add()`` is not noted.
|
|
324
337
|
"""
|
|
338
|
+
defined = self._defined_indexes.get(table)
|
|
339
|
+
if defined is not None:
|
|
340
|
+
defined.pop(name, None)
|
|
325
341
|
self._removed_indexes.setdefault(table, set()).add(name)
|
|
326
342
|
|
|
327
343
|
def _indexes_removed(self, table: str) -> frozenset[str]:
|
|
@@ -336,6 +352,30 @@ class Transaction(ABC):
|
|
|
336
352
|
if removed is not None:
|
|
337
353
|
removed.difference_update(names)
|
|
338
354
|
|
|
355
|
+
def _note_index_definition(self, table: str, name: str, analyzer: str, *, if_not_exists: bool = False) -> None:
|
|
356
|
+
"""Note that the index *name* of *table* was defined or redefined in this transaction with the analyzer
|
|
357
|
+
*analyzer* (``""`` for none) — issue #329.
|
|
358
|
+
|
|
359
|
+
``define_indexes(tx=…)`` calls it for each index it defines, once their ``DEFINE INDEX`` statements were applied
|
|
360
|
+
(interactive) or queued (buffered): a refusal notes nothing. ``remove_analyzer(tx=…)`` and
|
|
361
|
+
``define_analyzer(tx=…)``, which read committed state where the index is missing or holds another analyzer,
|
|
362
|
+
count it among the indexes that use *analyzer*. A removal noted before for the same name on *table* is forgotten
|
|
363
|
+
(:meth:`_forget_index_removals`), and a definition noted before replaced: the last change of a name wins. With
|
|
364
|
+
*if_not_exists* (a ``DEFINE INDEX IF NOT EXISTS``, ``define_indexes(overwrite=False, tx=…)``), a definition
|
|
365
|
+
noted before for the name is kept instead: the statement leaves the index the block defined earlier as it is.
|
|
366
|
+
The commit and the cancel keep it. A raw ``tx.add("DEFINE INDEX …")`` is not noted.
|
|
367
|
+
"""
|
|
368
|
+
defined = self._defined_indexes.setdefault(table, {})
|
|
369
|
+
if if_not_exists and name in defined:
|
|
370
|
+
return
|
|
371
|
+
self._forget_index_removals(table, (name,))
|
|
372
|
+
defined[name] = analyzer
|
|
373
|
+
|
|
374
|
+
def _indexes_defined(self) -> dict[str, dict[str, str]]:
|
|
375
|
+
"""The indexes defined in this transaction and not removed since, by table, each with its analyzer (``""`` for
|
|
376
|
+
none) — a copy, without the tables left with none (issue #329)."""
|
|
377
|
+
return {table: dict(indexes) for table, indexes in self._defined_indexes.items() if indexes}
|
|
378
|
+
|
|
339
379
|
def _note_analyzer_removal(self, name: str) -> None:
|
|
340
380
|
"""Note that the analyzer *name* was removed in this transaction — issue #323.
|
|
341
381
|
|
|
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.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/connection_config.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
|
{surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/testing/__init__.py
RENAMED
|
File without changes
|
{surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/testing/database.py
RENAMED
|
File without changes
|
{surreal_orm_lite-0.37.4 → surreal_orm_lite-0.37.6}/src/surreal_orm_lite/testing/fixtures.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|