surreal-orm-lite 0.36.1__tar.gz → 0.36.3__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.3}/CHANGELOG.md +87 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/PKG-INFO +24 -5
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/README.md +23 -4
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/pyproject.toml +1 -1
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/__init__.py +1 -1
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/model_base.py +60 -28
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/search.py +5 -5
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/transaction.py +29 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/vector.py +85 -16
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/.gitignore +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/LICENSE +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/Makefile +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/_sdk.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/aggregations.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/auth.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/cache.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/changefeed.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/concurrency.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/connection_config.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/connection_manager.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/constants.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/decoding.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/define_parser.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/edge.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/embedded.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/encoding.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/enum.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/exceptions.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/functions.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/geo.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/introspection.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/live.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/model_auth.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/model_ddl.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/model_generator.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/py.typed +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/q.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/query_set.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/routing.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/schema.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/schema_state.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/signals.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/subquery.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/surql_literal.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/testing/__init__.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/testing/database.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/testing/fixtures.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/time_travel.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/types.py +0 -0
- {surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/utils.py +0 -0
|
@@ -5,6 +5,93 @@ 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.3] - 2026-10-24
|
|
9
|
+
|
|
10
|
+
Follow-up to the review of v0.36.0 (#316): a vector field declared with `| None` keeps its
|
|
11
|
+
`Vector` marker, so the checks v0.36.0 added for vector fields apply to it too. No new public API.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- **A vector field written `VectorField[d] | None`, `Optional[VectorField[d]]` or
|
|
16
|
+
`Annotated[list[float], Vector(d)] | None` is read as a vector field** (#318). In these
|
|
17
|
+
spellings the marker sits inside a union member, not in the field's metadata, so since v0.36.0
|
|
18
|
+
`get_vector_info()` returned `None` and `is_vector_field()` `False` for them. The `class`
|
|
19
|
+
statement then skipped the vector-index check: an `Index(..., hnsw=True)` of another dimension
|
|
20
|
+
or storage type than the field was accepted, while `define_table()` still wrote
|
|
21
|
+
`option<array<float, d>>`, so the column and the index disagreed without an error; and
|
|
22
|
+
`similar_to()` took the expected length of the query vector from the index, not the field.
|
|
23
|
+
`get_vector_info()` and `is_vector_field()` now read the field's annotation when its metadata
|
|
24
|
+
holds no marker, as `define_table()` does: these spellings give the same column, the same
|
|
25
|
+
index checks at the `class` statement, the same dimension check in `similar_to()` and the same
|
|
26
|
+
`(dimension, storage type)` as `VectorField[d]`. Vectors held in a container
|
|
27
|
+
(`list[VectorField[d]]`) are still not a vector field.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- **A field with no single vector dimension is refused at the `class` statement** (#318): a
|
|
32
|
+
`Vector` marker next to a type other than `None` in a union (`VectorField[3] | str`), or two
|
|
33
|
+
different `Vector` markers on one field (`Annotated[VectorField[3], Vector(4)]`). The
|
|
34
|
+
`ValueError` names the model and the field and says to write `VectorField[d]` alone (it is
|
|
35
|
+
already optional) or `Annotated[list[float] | None, Vector(d)]`; the check runs on every model,
|
|
36
|
+
whether or not it declares indexes. Until v0.36.2 such a model was accepted (the first of two
|
|
37
|
+
markers decided the checks, a union with another type was not a vector field).
|
|
38
|
+
`get_vector_info()` and `is_vector_field()` raise the same `ValueError` for such a field or
|
|
39
|
+
annotation. Every spelling that v0.36.2 read as a vector field gives the same result.
|
|
40
|
+
|
|
41
|
+
### Notes
|
|
42
|
+
|
|
43
|
+
- **Docs**: README section 37 (Vector search) says `VectorField[d]` is already optional and
|
|
44
|
+
needs no `| None`: written with it, the field needs `= None`, since Pydantic ignores a default
|
|
45
|
+
inside a union member (with an `UnsupportedFieldAttributeWarning`) and the field is otherwise
|
|
46
|
+
required. It also says how the union spellings are read.
|
|
47
|
+
- The fix is in the ORM's model checks: the behaviour is the same on SurrealDB 2.x and 3.x and on
|
|
48
|
+
the embedded engine. Server pins unchanged: tested against SurrealDB 3.3.4 and 2.7.0, plus
|
|
49
|
+
3.1.5 for backward compatibility.
|
|
50
|
+
|
|
51
|
+
## [0.36.2] - 2026-10-23
|
|
52
|
+
|
|
53
|
+
Follow-ups to the review of v0.35.3 (#312): an index that `remove_index(tx=…)` removed earlier in
|
|
54
|
+
a transaction is defined again by `define_indexes(tx=…)` in the same block instead of being lost
|
|
55
|
+
at the commit, and the docs say why the refusal after a write covers every kind of index. No new
|
|
56
|
+
public API.
|
|
57
|
+
|
|
58
|
+
### Fixed
|
|
59
|
+
|
|
60
|
+
- **`remove_index(tx=…)` then `define_indexes(tx=…)` in one block no longer loses an existing
|
|
61
|
+
index** (#312). `define_indexes(tx=…)` reads `INFO FOR TABLE` outside the transaction, where an
|
|
62
|
+
index removed earlier in the block still stands: it planned nothing, returned `[]`, and the
|
|
63
|
+
commit applied the removal, leaving the table without the index and without an error (since
|
|
64
|
+
v0.35.0, over WebSocket and HTTP and on the embedded engine, on SurrealDB 2.x and 3.x).
|
|
65
|
+
`remove_index(tx=…)` now notes the removal on the transaction, and `define_indexes(tx=…)`
|
|
66
|
+
counts the noted index as missing: it defines it again after the removal
|
|
67
|
+
(`DEFINE INDEX OVERWRITE`, or `IF NOT EXISTS` with `overwrite=False`), so the commit keeps
|
|
68
|
+
it, and a later call in the block compares it with committed state again. Only an index the
|
|
69
|
+
model declares comes back: another model's index on the same table comes back with that
|
|
70
|
+
model's `define_indexes(tx=…)`, and one no model declares stays removed. When the block has
|
|
71
|
+
already written records to the table, the call is refused before any DDL, as since v0.35.3. A
|
|
72
|
+
raw `tx.add("REMOVE INDEX …")` is not tracked.
|
|
73
|
+
- **The same fix also applies to vector (HNSW) indexes since v0.36.0**: on v0.36.0 and v0.36.1,
|
|
74
|
+
`remove_index(tx=…)` then `define_indexes(tx=…)` lost an HNSW index at the commit on every
|
|
75
|
+
engine; it is now defined again, as a full-text or `UNIQUE` index is.
|
|
76
|
+
|
|
77
|
+
### Notes
|
|
78
|
+
|
|
79
|
+
- **Removing an index and defining it again in one block on SurrealDB 2.x**: on a table that
|
|
80
|
+
held records, the commit fails with a retryable `SurrealDbConflictError` that a retry meets
|
|
81
|
+
again, a 2.x limitation; nothing of the block is committed and the index stands as before. On an
|
|
82
|
+
empty table it commits, as on SurrealDB 3.x and the embedded engine. A row in each behaviour
|
|
83
|
+
table of the README ("ORM behaviour: SurrealDB 2.x vs 3.x" and the embedded engine's) describes
|
|
84
|
+
each engine's outcome, which tests pin.
|
|
85
|
+
- **A write after `define_indexes(tx=…)` on SurrealDB 2.x**: the v0.35.3 qualifier "to a table
|
|
86
|
+
that held records" is now pinned: on an empty table, a write after the index in the same block
|
|
87
|
+
commits and is indexed.
|
|
88
|
+
- **Docs**: README section 36 (Transactions) and the `define_indexes()` docstring say why the
|
|
89
|
+
refusal after a write covers every kind of index, not only full-text ones: a search would miss
|
|
90
|
+
those records, and a `UNIQUE` index missing them would not enforce uniqueness for them
|
|
91
|
+
([surrealdb/surrealdb#7618](https://github.com/surrealdb/surrealdb/issues/7618)).
|
|
92
|
+
- Server pins unchanged: tested against SurrealDB 3.3.4 and 2.7.0 and on the embedded engine,
|
|
93
|
+
plus 3.1.5 for backward compatibility.
|
|
94
|
+
|
|
8
95
|
## [0.36.1] - 2026-10-23
|
|
9
96
|
|
|
10
97
|
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.3
|
|
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
|
|
@@ -6290,6 +6299,14 @@ print(get_vector_info(Document.model_fields["embedding"]), is_vector_field(Passa
|
|
|
6290
6299
|
# (3, 'F32') False
|
|
6291
6300
|
```
|
|
6292
6301
|
|
|
6302
|
+
`VectorField[d]` is already optional, so it needs no `| None`. Written `VectorField[d] | None` or
|
|
6303
|
+
`Optional[VectorField[d]]`, its `None` default sits inside a union member, where Pydantic ignores it with an
|
|
6304
|
+
`UnsupportedFieldAttributeWarning`: write `= None`, or the field is required. The ORM reads these spellings, and
|
|
6305
|
+
`Annotated[list[float], Vector(d)] | None`, like the plain ones: the same column, the same checks of the vector index
|
|
6306
|
+
when the class is defined, the same dimension for `similar_to()`, the same answer from `get_vector_info()`. A union
|
|
6307
|
+
that holds a vector next to a type other than `None`, or two different `Vector` markers, has no single dimension: the
|
|
6308
|
+
class statement refuses it, naming the field.
|
|
6309
|
+
|
|
6293
6310
|
#### Find the nearest
|
|
6294
6311
|
|
|
6295
6312
|
`similar_to(field, vector, limit=10, *, ef=None, dist=None)` keeps the `limit` records whose `field` vector is nearest
|
|
@@ -6597,7 +6614,7 @@ features introduced in SurrealDB 3.x. On 2.x the ORM degrades gracefully. Capabi
|
|
|
6597
6614
|
listed behave the same on both lines. The 2.x column was measured on 2.6.5 and holds unchanged
|
|
6598
6615
|
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
6616
|
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.
|
|
6617
|
+
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
6618
|
The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded engine](#orm-behaviour-the-embedded-engine).
|
|
6602
6619
|
|
|
6603
6620
|
| ORM capability | SurrealDB 2.6.x / 2.7.x | SurrealDB 3.2.x / 3.3.x | Since |
|
|
@@ -6757,6 +6774,7 @@ The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded
|
|
|
6757
6774
|
| `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
6775
|
| `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
6776
|
| `similar_to()` on a field without a vector index | no record | no record; 3.1 answers every record, with no distance | v0.36.0 |
|
|
6777
|
+
| `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
6778
|
| 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
6779
|
|
|
6762
6780
|
> **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 +6814,7 @@ Capabilities not listed behave as on a 2.x server.
|
|
|
6796
6814
|
| 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
6815
|
| `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
6816
|
| 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 |
|
|
6817
|
+
| `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
6818
|
| 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
6819
|
|
|
6801
6820
|
---
|
|
@@ -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
|
|
@@ -6239,6 +6248,14 @@ print(get_vector_info(Document.model_fields["embedding"]), is_vector_field(Passa
|
|
|
6239
6248
|
# (3, 'F32') False
|
|
6240
6249
|
```
|
|
6241
6250
|
|
|
6251
|
+
`VectorField[d]` is already optional, so it needs no `| None`. Written `VectorField[d] | None` or
|
|
6252
|
+
`Optional[VectorField[d]]`, its `None` default sits inside a union member, where Pydantic ignores it with an
|
|
6253
|
+
`UnsupportedFieldAttributeWarning`: write `= None`, or the field is required. The ORM reads these spellings, and
|
|
6254
|
+
`Annotated[list[float], Vector(d)] | None`, like the plain ones: the same column, the same checks of the vector index
|
|
6255
|
+
when the class is defined, the same dimension for `similar_to()`, the same answer from `get_vector_info()`. A union
|
|
6256
|
+
that holds a vector next to a type other than `None`, or two different `Vector` markers, has no single dimension: the
|
|
6257
|
+
class statement refuses it, naming the field.
|
|
6258
|
+
|
|
6242
6259
|
#### Find the nearest
|
|
6243
6260
|
|
|
6244
6261
|
`similar_to(field, vector, limit=10, *, ef=None, dist=None)` keeps the `limit` records whose `field` vector is nearest
|
|
@@ -6546,7 +6563,7 @@ features introduced in SurrealDB 3.x. On 2.x the ORM degrades gracefully. Capabi
|
|
|
6546
6563
|
listed behave the same on both lines. The 2.x column was measured on 2.6.5 and holds unchanged
|
|
6547
6564
|
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
6565
|
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.
|
|
6566
|
+
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
6567
|
The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded engine](#orm-behaviour-the-embedded-engine).
|
|
6551
6568
|
|
|
6552
6569
|
| ORM capability | SurrealDB 2.6.x / 2.7.x | SurrealDB 3.2.x / 3.3.x | Since |
|
|
@@ -6706,6 +6723,7 @@ The SDK's in-process engine has a table of its own: [ORM behaviour: the embedded
|
|
|
6706
6723
|
| `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
6724
|
| `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
6725
|
| `similar_to()` on a field without a vector index | no record | no record; 3.1 answers every record, with no distance | v0.36.0 |
|
|
6726
|
+
| `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
6727
|
| 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
6728
|
|
|
6711
6729
|
> **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 +6763,7 @@ Capabilities not listed behave as on a 2.x server.
|
|
|
6745
6763
|
| 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
6764
|
| `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
6765
|
| 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 |
|
|
6766
|
+
| `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
6767
|
| 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
6768
|
|
|
6750
6769
|
---
|
|
@@ -114,7 +114,7 @@ from .utils import (
|
|
|
114
114
|
validate_thing,
|
|
115
115
|
warn_on_multiple_statements,
|
|
116
116
|
)
|
|
117
|
-
from .vector import
|
|
117
|
+
from .vector import declared_vectors
|
|
118
118
|
|
|
119
119
|
if TYPE_CHECKING:
|
|
120
120
|
from .edge import BaseSurrealEdge
|
|
@@ -877,12 +877,16 @@ class BaseSurrealModel(BaseModel):
|
|
|
877
877
|
names — an inherited value is checked again, the messages naming the subclass. So is the
|
|
878
878
|
``view_query`` key (v0.32.0): ``None``, or one ``SELECT`` (``schema.check_view_query()``)
|
|
879
879
|
on a model that is not an edge, does not mix in ``AuthenticatedUserMixin`` and declares no
|
|
880
|
-
computed field (``schema.check_view_config()``) — inherited values included. So
|
|
881
|
-
after it, the ``
|
|
880
|
+
computed field (``schema.check_view_config()``) — inherited values included. So are, right
|
|
881
|
+
after it and on every model, the ``Vector`` markers of the fields (``vector.declared_vectors()``):
|
|
882
|
+
a field holding two different markers, or a marker next to a type other than ``None`` in a
|
|
883
|
+
union, is refused, naming it — inherited fields included, the message naming the subclass. So
|
|
884
|
+
is then the ``indexes`` key (v0.35.0, ``search.check_indexes_config()``): ``None``, or a
|
|
882
885
|
``list`` or ``tuple`` of ``Index`` with distinct names, none on a view, one full-text index
|
|
883
886
|
per column and one ``Analyzer`` definition per analyzer name, one vector index per column
|
|
884
|
-
and, on a vector field
|
|
885
|
-
included, the messages naming the subclass.
|
|
887
|
+
and, on a vector field of any spelling — a union with ``None`` included —, of its dimension
|
|
888
|
+
and storage type (v0.36.0) — inherited values included, the messages naming the subclass.
|
|
889
|
+
So are the ``table_type``, ``relation_in``,
|
|
886
890
|
``relation_out`` and ``enforced`` keys (v0.33.0), when any of them is not ``None``: a
|
|
887
891
|
``TableType`` (``RELATION`` on an edge only), and the relation keys on an edge model only
|
|
888
892
|
(``schema.check_relation_config()``). So are, on every model and after the relation keys,
|
|
@@ -915,13 +919,11 @@ class BaseSurrealModel(BaseModel):
|
|
|
915
919
|
user=issubclass(cls, AuthenticatedUserMixin),
|
|
916
920
|
computed=tuple(cls.__surreal_computed__),
|
|
917
921
|
)
|
|
922
|
+
# Every model, with or without indexes: a field whose Vector markers are ambiguous is refused here.
|
|
923
|
+
declared = declared_vectors(cls.__name__, cls.model_fields)
|
|
918
924
|
indexes = cls.model_config.get("indexes")
|
|
919
925
|
if indexes is not None:
|
|
920
|
-
vectors = {
|
|
921
|
-
cls.to_db_field(name): info
|
|
922
|
-
for name, field in cls.model_fields.items()
|
|
923
|
-
if (info := get_vector_info(field)) is not None
|
|
924
|
-
}
|
|
926
|
+
vectors = {cls.to_db_field(name): info for name, info in declared.items()}
|
|
925
927
|
check_indexes_config(cls, indexes, view=cls._is_view(), column=cls.to_db_field, vectors=vectors)
|
|
926
928
|
relation = {key: cls.model_config.get(key) for key in ("table_type", "relation_in", "relation_out", "enforced")}
|
|
927
929
|
if any(value is not None for value in relation.values()):
|
|
@@ -1304,19 +1306,31 @@ class BaseSurrealModel(BaseModel):
|
|
|
1304
1306
|
Before any DDL (nothing sent but the reads): an index that names by ``str`` an analyzer neither the database
|
|
1305
1307
|
nor the model's ``Analyzer`` objects define is refused; with *tx*, an analyzer to define or redefine is refused
|
|
1306
1308
|
— 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
|
-
|
|
1309
|
+
outside the block. With *tx*, an index to define or redefine (one removed in the block included) is also refused
|
|
1310
|
+
when the transaction has already written records to the model's table — an ORM write (``save()``,
|
|
1311
|
+
``objects(tx=…).bulk_create()``, …) or one noted on every table; a definition such as ``define_table(tx=…)``
|
|
1312
|
+
does not count, nor does a raw ``tx.add()``, which the ORM does not track: SurrealDB servers do not index the
|
|
1313
|
+
records a transaction wrote before the index was defined, which stay out of it after the commit — a server
|
|
1314
|
+
defect (surrealdb/surrealdb#7618 on 3.x, the same on 2.x; the embedded engine indexes them). Every kind of
|
|
1315
|
+
index is refused, not only a full-text one: a search would miss those records, and a ``UNIQUE`` index would
|
|
1316
|
+
not enforce uniqueness for them. The refusal does not fail the transaction; call ``define_indexes()`` without
|
|
1317
|
+
*tx* first. With *tx* and the analyzers in place, the index statements join the transaction — applied at once
|
|
1318
|
+
in an interactive one (WebSocket, SurrealDB 3.x), at the commit in a buffered one (HTTP, SurrealDB 2.x, the
|
|
1319
|
+
embedded engine), where a refusal comes back as the transaction's own error; a block that raises applies
|
|
1320
|
+
nothing. On SurrealDB 2.x, a write to a table that held records, after its index in the same block, fails the
|
|
1321
|
+
commit with a retryable ``SurrealDbConflictError`` that a retry meets again; on an empty table it commits, as on
|
|
1322
|
+
3.x. In a buffered transaction an index queued earlier in the block is not seen by the reads, and is queued
|
|
1323
|
+
again (the same statement). Every cached read is dropped.
|
|
1324
|
+
|
|
1325
|
+
**An index removed in the transaction.** With *tx*, an index :meth:`remove_index` removed with the same *tx*
|
|
1326
|
+
counts as missing, although the committed state the reads see still holds it: it is defined again after its
|
|
1327
|
+
removal (``DEFINE INDEX OVERWRITE``, or ``IF NOT EXISTS`` without *overwrite*), so the commit keeps it; a later
|
|
1328
|
+
call in the block compares it with committed state again. Only an index this model declares is defined again:
|
|
1329
|
+
another model's on the same table comes back with that model's ``define_indexes(tx=…)``, and one no model
|
|
1330
|
+
declares stays removed. A raw ``tx.add("REMOVE INDEX …")`` is not tracked. On SurrealDB 2.x, on a table that
|
|
1331
|
+
held records, a block that removes an index and defines it again fails the commit with a retryable
|
|
1332
|
+
``SurrealDbConflictError`` that a retry meets again: nothing of the block is committed and the index stands as
|
|
1333
|
+
before; on an empty table it commits, as on 3.x.
|
|
1320
1334
|
|
|
1321
1335
|
Names are written in backticks, filters re-rendered from a closed grammar, numbers from Python numbers,
|
|
1322
1336
|
comments as string literals. A refusal names the analyzer or the index and its table, never the statement:
|
|
@@ -1328,15 +1342,16 @@ class BaseSurrealModel(BaseModel):
|
|
|
1328
1342
|
overwrite: ``True`` (default) redefines a changed analyzer or index — the model wins. ``False`` defines
|
|
1329
1343
|
what is missing (``IF NOT EXISTS``) and leaves what exists as it is.
|
|
1330
1344
|
tx: optional transaction the index statements are applied with; the reads happen before anything is
|
|
1331
|
-
queued.
|
|
1345
|
+
queued. An index :meth:`remove_index` removed with it counts as missing.
|
|
1332
1346
|
|
|
1333
1347
|
Raises:
|
|
1334
1348
|
TypeError: *overwrite* is not a ``bool`` — before any request.
|
|
1335
1349
|
SurrealDbError: *tx* belongs to another connection — before any request; an analyzer named by ``str`` does
|
|
1336
1350
|
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
|
|
1351
|
+
or redefined (one removed in the block included) after the transaction wrote records to the model's
|
|
1352
|
+
table (the message names the model and the table) — before any DDL; the server refused a statement
|
|
1353
|
+
(``Can't apply analyzer definition: …``, ``Can't apply index definition: …``, ``Can't apply index
|
|
1354
|
+
rebuild: …``).
|
|
1340
1355
|
SurrealDbAuthenticationError: the session may not read the definitions or define the analyzers and
|
|
1341
1356
|
indexes.
|
|
1342
1357
|
|
|
@@ -1377,6 +1392,11 @@ class BaseSurrealModel(BaseModel):
|
|
|
1377
1392
|
if any(index.search_analyzer is not None for index in indexes):
|
|
1378
1393
|
keyword = fulltext_keyword(_time_travel.line_major(await client.version()))
|
|
1379
1394
|
stored_indexes = await read_table_indexes(client, table, what="index", kind="definition")
|
|
1395
|
+
# Issue #312: an index remove_index(tx=…) removed in this transaction still stands in committed state; it is
|
|
1396
|
+
# missing once the transaction commits, so it is planned as missing (DEFINE INDEX after the removal).
|
|
1397
|
+
removed = tx._indexes_removed(table) if isinstance(tx, Transaction) else frozenset()
|
|
1398
|
+
if removed:
|
|
1399
|
+
stored_indexes = {name: state for name, state in stored_indexes.items() if name not in removed}
|
|
1380
1400
|
redefined = {analyzer.name for analyzer in redefine}
|
|
1381
1401
|
definitions, rebuilds = plan_indexes(
|
|
1382
1402
|
indexes,
|
|
@@ -1414,6 +1434,8 @@ class BaseSurrealModel(BaseModel):
|
|
|
1414
1434
|
classify=True,
|
|
1415
1435
|
subjects=[index_subject(name, table) for name, _ in definitions],
|
|
1416
1436
|
)
|
|
1437
|
+
if removed and isinstance(tx, Transaction):
|
|
1438
|
+
tx._forget_index_removals(table, (name for name, _ in definitions))
|
|
1417
1439
|
applied += await apply_rebuilds(client, tx, own_rebuilds)
|
|
1418
1440
|
warn_redefined(redefine, [*other_rebuilds, *redefined_indexes, *own_rebuilds])
|
|
1419
1441
|
return applied
|
|
@@ -1429,11 +1451,18 @@ class BaseSurrealModel(BaseModel):
|
|
|
1429
1451
|
not starting with a digit), checked before any request. The model's cached reads are dropped. A ``search()`` of
|
|
1430
1452
|
the field afterwards raises ``SurrealDbError`` until an index covers it again.
|
|
1431
1453
|
|
|
1454
|
+
With *tx*, the transaction notes the removal: :meth:`define_indexes` called later with the same *tx* counts the
|
|
1455
|
+
index as missing, although committed state still holds it, and defines it again after the removal when its
|
|
1456
|
+
model declares it — so removing an index and defining it again in one block keeps it. On SurrealDB 2.x, on a
|
|
1457
|
+
table that held records, such a block fails the commit with a retryable ``SurrealDbConflictError`` that a retry
|
|
1458
|
+
meets again, and nothing of it is committed. A raw ``tx.add("REMOVE INDEX …")`` is not noted.
|
|
1459
|
+
|
|
1432
1460
|
Args:
|
|
1433
1461
|
name: the index's name.
|
|
1434
1462
|
missing_ok: ``True`` (default) emits ``REMOVE INDEX IF EXISTS …``, so a missing index is not an error;
|
|
1435
1463
|
``False`` raises ``SurrealDbNotFoundError`` for it.
|
|
1436
|
-
tx: optional transaction the statement is applied with
|
|
1464
|
+
tx: optional transaction the statement is applied with; it notes the removal for
|
|
1465
|
+
:meth:`define_indexes`.
|
|
1437
1466
|
|
|
1438
1467
|
Raises:
|
|
1439
1468
|
TypeError, ValueError: *name* is not an identifier, or *missing_ok* not a ``bool`` — before any request.
|
|
@@ -1462,6 +1491,9 @@ class BaseSurrealModel(BaseModel):
|
|
|
1462
1491
|
classify=True,
|
|
1463
1492
|
subjects=[index_subject(name, table)],
|
|
1464
1493
|
)
|
|
1494
|
+
if isinstance(tx, Transaction):
|
|
1495
|
+
# Issue #312: define_indexes(tx=…) reads committed state, where the index still stands.
|
|
1496
|
+
tx._note_index_removal(table, name)
|
|
1465
1497
|
return statement
|
|
1466
1498
|
|
|
1467
1499
|
# ==================== Materialized views (v0.32.0) ====================
|
|
@@ -833,11 +833,11 @@ def check_indexes_config(
|
|
|
833
833
|
by *column* — the model's ``to_db_field`` — so an aliased field counts under its column (SurrealDB would use either
|
|
834
834
|
for ``search()``, with different scores); two different ``Analyzer`` objects share a name (an analyzer belongs to
|
|
835
835
|
the database: one definition per name); two vector indexes cover one column, counted the same way (SurrealDB would
|
|
836
|
-
use either for ``similar_to()``); a vector index on a vector field — *vectors* maps the column of each,
|
|
837
|
-
spelling, to its ``(dimension, storage type)`` — whose dimension or storage type
|
|
838
|
-
index's effective type compared (``F32`` when it declares none,
|
|
839
|
-
column that is not a vector field is not checked against it. Each
|
|
840
|
-
messages name *model*.
|
|
836
|
+
use either for ``similar_to()``); a vector index on a vector field — *vectors* maps the column of each, any
|
|
837
|
+
spelling (a union with ``None`` included), to its ``(dimension, storage type)`` — whose dimension or storage type
|
|
838
|
+
differs from the field's, the index's effective type compared (``F32`` when it declares none,
|
|
839
|
+
``Index._hnsw_options()``). A vector index on a column that is not a vector field is not checked against it. Each
|
|
840
|
+
``Index`` was checked when it was built. The messages name *model*.
|
|
841
841
|
|
|
842
842
|
:raises TypeError: *value* is not a ``list`` or a ``tuple``, or holds something other than an ``Index``.
|
|
843
843
|
:raises ValueError: two indexes share a name; a view declares an index; two full-text indexes cover one column;
|
|
@@ -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:
|
|
@@ -8,7 +8,11 @@ storage type is given (``F64``, ``F32``, ``I64``, ``I32`` or ``I16``, in any cas
|
|
|
8
8
|
Pydantic reads the ``Vector`` marker exactly as ``VectorField[1536]``'s. Both spellings are one field: the same
|
|
9
9
|
validation, the same column type (``option<array<float, 1536>>``), the same schema. ``get_vector_info()`` and
|
|
10
10
|
``is_vector_field()`` — the full ORM's helpers, under their names — read the marker of either spelling from a model
|
|
11
|
-
field or an annotation
|
|
11
|
+
field or an annotation, and of their unions with ``None`` (``VectorField[1536] | None``,
|
|
12
|
+
``Annotated[list[float], Vector(1536)] | None``), as ``define_table()`` reads them; never from inside a container
|
|
13
|
+
(``list[VectorField[3]]``). A field or an annotation holding two different markers, or a marker next to a type other
|
|
14
|
+
than ``None``, has no single dimension: the helpers refuse it, and a model's ``class`` statement refuses such a field
|
|
15
|
+
(``declared_vectors()``).
|
|
12
16
|
|
|
13
17
|
A value is ``None`` or a ``list``/``tuple`` of exactly ``d`` real numbers — ``int``, ``float``, any ``numbers.Real``,
|
|
14
18
|
a ``decimal.Decimal`` (SurrealDB's decimals read back as ``Decimal``) —, never a ``bool`` nor a ``str``, each finite
|
|
@@ -50,7 +54,8 @@ from collections.abc import Mapping, Sequence
|
|
|
50
54
|
from dataclasses import dataclass
|
|
51
55
|
from decimal import Decimal
|
|
52
56
|
from numbers import Real
|
|
53
|
-
from
|
|
57
|
+
from types import NoneType, UnionType
|
|
58
|
+
from typing import Annotated, Any, NoReturn, Self, TypedDict, Union, get_args, get_origin
|
|
54
59
|
|
|
55
60
|
from pydantic import Field, GetCoreSchemaHandler, GetJsonSchemaHandler
|
|
56
61
|
from pydantic.fields import FieldInfo
|
|
@@ -292,38 +297,102 @@ class VectorField:
|
|
|
292
297
|
return _ANNOTATED[list[float] | None, Vector(*checked), Field(default=None)]
|
|
293
298
|
|
|
294
299
|
|
|
295
|
-
def
|
|
296
|
-
"""The
|
|
300
|
+
def _held(annotation: Any, metadata: Sequence[Any] = ()) -> tuple[tuple[Vector, ...], bool]:
|
|
301
|
+
"""The distinct ``Vector`` markers that declare a field of *annotation* (with the field's own *metadata*), in order,
|
|
302
|
+
and whether the field also takes a type other than ``None`` next to them.
|
|
303
|
+
|
|
304
|
+
The ``Annotated`` layers are unwrapped and their metadata added to *metadata*: when it holds a ``Vector``, those
|
|
305
|
+
markers decide, whatever the type under them (a ``Vector`` validates the value itself). Otherwise ``None`` gives
|
|
306
|
+
neither; a union gives the markers and other types of its members, each read the same way; any other type is
|
|
307
|
+
another type — a container holding vectors (``list[VectorField[3]]``) included, whose arguments are never read.
|
|
308
|
+
This is the reading ``model_ddl`` gives the column its kind by, so the column and the checks agree.
|
|
309
|
+
"""
|
|
310
|
+
while get_origin(annotation) is Annotated:
|
|
311
|
+
metadata = (*metadata, *annotation.__metadata__)
|
|
312
|
+
annotation = annotation.__origin__
|
|
313
|
+
markers = tuple(dict.fromkeys(item for item in metadata if isinstance(item, Vector)))
|
|
314
|
+
if markers:
|
|
315
|
+
return markers, False
|
|
316
|
+
if annotation is None or annotation is NoneType:
|
|
317
|
+
return (), False
|
|
318
|
+
origin = get_origin(annotation)
|
|
319
|
+
if origin is not Union and origin is not UnionType:
|
|
320
|
+
return (), True
|
|
321
|
+
members = [_held(member) for member in get_args(annotation)]
|
|
322
|
+
markers = tuple(dict.fromkeys(marker for held, _ in members for marker in held))
|
|
323
|
+
return markers, any(other for _, other in members)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def ambiguous_marker_refused(subject: str, markers: Sequence[Vector], other: bool) -> str:
|
|
327
|
+
"""The refusal of *subject* — a field, or an annotation —, which holds several different *markers*, or a marker and
|
|
328
|
+
a type other than ``None`` (*other*): a vector field of no single dimension and storage type."""
|
|
329
|
+
held = repr(markers[-1]) if len(markers) == 1 else f"{', '.join(map(repr, markers[:-1]))} and {markers[-1]!r}"
|
|
330
|
+
if other:
|
|
331
|
+
held += " next to a type other than None"
|
|
332
|
+
return (
|
|
333
|
+
f"{subject} holds {held}; a vector field holds one Vector marker, and None at most. Write VectorField[d] alone "
|
|
334
|
+
"(it is already optional) or Annotated[list[float] | None, Vector(d)]."
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def _marker(annotation_or_field: Any, *, subject: str | None = None) -> Vector | None:
|
|
339
|
+
"""The ``Vector`` marker of a ``FieldInfo`` or of an annotation (``_held()``), ``None`` when it holds none.
|
|
340
|
+
|
|
341
|
+
Several different markers, or a marker next to a type other than ``None`` in a union, raise ``ValueError`` naming
|
|
342
|
+
*subject* (by default "The field" or "The annotation").
|
|
343
|
+
"""
|
|
297
344
|
if isinstance(annotation_or_field, FieldInfo):
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
metadata = annotation_or_field.__metadata__
|
|
345
|
+
markers, other = _held(annotation_or_field.annotation, annotation_or_field.metadata)
|
|
346
|
+
default = "The field"
|
|
301
347
|
else:
|
|
348
|
+
markers, other = _held(annotation_or_field)
|
|
349
|
+
default = "The annotation"
|
|
350
|
+
if not markers:
|
|
302
351
|
return None
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if isinstance(annotation_or_field, FieldInfo):
|
|
307
|
-
return None
|
|
308
|
-
return _marker(get_args(annotation_or_field)[0])
|
|
352
|
+
if len(markers) > 1 or other:
|
|
353
|
+
raise ValueError(ambiguous_marker_refused(subject or default, markers, other))
|
|
354
|
+
return markers[0]
|
|
309
355
|
|
|
310
356
|
|
|
311
357
|
def get_vector_info(annotation_or_field: Any) -> tuple[int, str] | None:
|
|
312
358
|
"""The ``(dimension, storage type)`` of a vector field, or ``None`` when it is not one (the full ORM's helper).
|
|
313
359
|
|
|
314
360
|
Takes a model field (``Model.model_fields["embedding"]``, a Pydantic ``FieldInfo``) or an annotation
|
|
315
|
-
(``VectorField[3]``, ``Annotated[list[float] | None, Vector(3)]``): both spellings give ``(3, "F32")
|
|
316
|
-
|
|
361
|
+
(``VectorField[3]``, ``Annotated[list[float] | None, Vector(3)]``): both spellings give ``(3, "F32")``, and so do
|
|
362
|
+
their unions with ``None`` (``VectorField[3] | None``, ``Optional[VectorField[3]]``,
|
|
363
|
+
``Annotated[list[float], Vector(3)] | None``), read as ``define_table()`` reads them. Anything without a ``Vector``
|
|
364
|
+
marker — ``list[float]``, another field, vectors held in a container such as ``list[VectorField[3]]`` — gives
|
|
365
|
+
``None``.
|
|
366
|
+
|
|
367
|
+
:raises ValueError: the field or annotation holds two different ``Vector`` markers, or a marker next to a type
|
|
368
|
+
other than ``None`` in a union (``VectorField[3] | str``): its dimension and storage type are not one. A
|
|
369
|
+
model's ``class`` statement refuses such a field already, naming it.
|
|
317
370
|
"""
|
|
318
371
|
marker = _marker(annotation_or_field)
|
|
319
372
|
return None if marker is None else (marker.dimension, marker.vector_type)
|
|
320
373
|
|
|
321
374
|
|
|
322
375
|
def is_vector_field(annotation_or_field: Any) -> bool:
|
|
323
|
-
"""Whether a model field or an annotation is a vector field,
|
|
376
|
+
"""Whether a model field or an annotation is a vector field, any spelling — a union with ``None`` included — (the
|
|
377
|
+
full ORM's helper). Refuses what ``get_vector_info()`` refuses, with its ``ValueError``."""
|
|
324
378
|
return _marker(annotation_or_field) is not None
|
|
325
379
|
|
|
326
380
|
|
|
381
|
+
def declared_vectors(owner: str, fields: Mapping[str, FieldInfo]) -> dict[str, tuple[int, str]]:
|
|
382
|
+
"""The ``(dimension, storage type)`` of each vector field among a model's *fields*, by field name, as
|
|
383
|
+
``get_vector_info()`` reads them: what the model's ``class`` statement checks (issue #318).
|
|
384
|
+
|
|
385
|
+
A field whose ``Vector`` markers are ambiguous raises ``ValueError`` naming the model *owner* and the field, so the
|
|
386
|
+
``class`` statement refuses it whether or not the model declares indexes.
|
|
387
|
+
"""
|
|
388
|
+
declared: dict[str, tuple[int, str]] = {}
|
|
389
|
+
for name, field in fields.items():
|
|
390
|
+
marker = _marker(field, subject=f"{owner}: field {name!r}")
|
|
391
|
+
if marker is not None:
|
|
392
|
+
declared[name] = (marker.dimension, marker.vector_type)
|
|
393
|
+
return declared
|
|
394
|
+
|
|
395
|
+
|
|
327
396
|
# --- the checks -----------------------------------------------------------------------------------------------------
|
|
328
397
|
|
|
329
398
|
|
|
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.3}/src/surreal_orm_lite/connection_config.py
RENAMED
|
File without changes
|
{surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/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
|
{surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/testing/__init__.py
RENAMED
|
File without changes
|
{surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/testing/database.py
RENAMED
|
File without changes
|
{surreal_orm_lite-0.36.1 → surreal_orm_lite-0.36.3}/src/surreal_orm_lite/testing/fixtures.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|