surreal-orm-lite 0.37.7__tar.gz → 0.38.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/CHANGELOG.md +94 -0
  2. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/PKG-INFO +358 -23
  3. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/README.md +357 -22
  4. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/pyproject.toml +1 -1
  5. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/__init__.py +15 -2
  6. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/introspection.py +88 -7
  7. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/__init__.py +82 -0
  8. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/autodetect.py +148 -0
  9. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/compare.py +435 -0
  10. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/constants.py +9 -0
  11. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/executor.py +1184 -0
  12. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/generator.py +370 -0
  13. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/introspector.py +217 -0
  14. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/loader.py +224 -0
  15. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/migration.py +217 -0
  16. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/operations.py +1993 -0
  17. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/render.py +709 -0
  18. surreal_orm_lite-0.38.2/src/surreal_orm_lite/migrations/state.py +695 -0
  19. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/model_auth.py +52 -33
  20. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/model_base.py +39 -0
  21. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/model_ddl.py +5 -3
  22. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/model_generator.py +14 -4
  23. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/schema.py +83 -0
  24. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/schema_state.py +104 -12
  25. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/.gitignore +0 -0
  26. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/LICENSE +0 -0
  27. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/Makefile +0 -0
  28. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/_sdk.py +0 -0
  29. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/aggregations.py +0 -0
  30. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/auth.py +0 -0
  31. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/cache.py +0 -0
  32. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/changefeed.py +0 -0
  33. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/concurrency.py +0 -0
  34. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/connection_config.py +0 -0
  35. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/connection_manager.py +0 -0
  36. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/constants.py +0 -0
  37. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/decoding.py +0 -0
  38. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/define_parser.py +0 -0
  39. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/edge.py +0 -0
  40. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/embedded.py +0 -0
  41. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/encoding.py +0 -0
  42. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/enum.py +0 -0
  43. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/exceptions.py +0 -0
  44. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/functions.py +0 -0
  45. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/geo.py +0 -0
  46. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/hybrid.py +0 -0
  47. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/live.py +0 -0
  48. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/py.typed +0 -0
  49. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/q.py +0 -0
  50. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/query_set.py +0 -0
  51. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/routing.py +0 -0
  52. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/search.py +0 -0
  53. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/signals.py +0 -0
  54. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/subquery.py +0 -0
  55. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/surql_literal.py +0 -0
  56. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/testing/__init__.py +0 -0
  57. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/testing/database.py +0 -0
  58. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/testing/fixtures.py +0 -0
  59. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/time_travel.py +0 -0
  60. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/transaction.py +0 -0
  61. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/types.py +0 -0
  62. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/utils.py +0 -0
  63. {surreal_orm_lite-0.37.7 → surreal_orm_lite-0.38.2}/src/surreal_orm_lite/vector.py +0 -0
@@ -5,6 +5,100 @@ 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.38.2] - 2026-10-30
9
+
10
+ ### Fixed
11
+
12
+ - **`define_table()` keeps a stored `DEFAULT ALWAYS`** when the model declares the default: over a
13
+ field stored with `DEFAULT ALWAYS`, it now writes `DEFAULT ALWAYS <model default>`, as the
14
+ migration diff does, instead of dropping `ALWAYS` (#368). A plain stored `DEFAULT`, or none, still
15
+ gives a plain `DEFAULT`. Same on SurrealDB 2.x and 3.x.
16
+
17
+ ## [0.38.0] - 2026-10-28
18
+
19
+ Migration system: the ORM writes Django-style migration files from the models and applies them,
20
+ with the full SurrealDB-ORM's API (`makemigrations()`, `MigrationExecutor.migrate()`,
21
+ `rollback()`, `upgrade()`, the operations). Each migration is applied atomically, in one
22
+ SurrealDB transaction together with its record in the `_surreal_orm_migrations` tracking table,
23
+ on SurrealDB 3.x, 2.x and the embedded engine. The first minor of Tier 3's tooling phase.
24
+
25
+ ### Added
26
+
27
+ - **`surreal_orm_lite.migrations`**: `Migration`, `Operation` and the operations `CreateTable`,
28
+ `AlterTable`, `DropTable`, `AddField`, `AlterField`, `DropField`, `CreateIndex`, `DropIndex`,
29
+ `RebuildIndex`, `DefineAnalyzer`, `RemoveAnalyzer`, `DefineEvent`, `RemoveEvent`,
30
+ `DefineAccess`, `RemoveAccess`, `DefineFunction`, `RemoveFunction`, `DataMigration` and
31
+ `RawSQL`, with `Operation.state_forwards()`/`state_backwards()`; `DefaultExpression` (an
32
+ addition: a SurrealQL default for the DDL only); `split_destructive()`; `MigrationGenerator` and
33
+ `generate_empty_migration()`; `MigrationExecutor` (`migrate()`, `rollback()`, `upgrade()`,
34
+ `get_migration_status()`, `show_sql()`, `migration_state()`) and `MigrationStatementError`;
35
+ `ModelIntrospector` and `introspect_models()`; `makemigrations()`; `MIGRATIONS_TABLE`; and,
36
+ re-exported as the full ORM's `migrations` package does, `DatabaseIntrospector` and
37
+ `ModelCodeGenerator`.
38
+ - **`makemigrations()`** reads the connected database by default and replays the migration files
39
+ not yet applied on top (the full ORM CLI's `--from-db`); `from_db=False` diffs against the files
40
+ alone, offline. `drop_missing=True` writes the removals of what the models no longer declare.
41
+ - **`schema_diff()`** (top level and `surreal_orm_lite.introspection`) lists the operations that
42
+ would bring the database to the models, `[]` when they agree; **`get_registered_models()`**
43
+ (top level) lists the model classes defined. The top level also exports `DefineAnalyzer`,
44
+ `DefineEvent`, `RebuildIndex` and `RemoveEvent`, as the full ORM's does.
45
+ - **`SchemaState.diff(target)`** and **`SchemaState.applied_migrations`** (the full ORM's 2nd
46
+ attribute, positional at its 2nd place); `FieldState.server`, `FieldState.undeclared` and
47
+ `TableState.undeclared` (keyword-only: the marks of a state built from models).
48
+ - README section 39, "Migrations (`makemigrations()`, `MigrationExecutor`, operations)" (write,
49
+ apply, change the models, data migrations, roll back, the operations, drift, server lines,
50
+ limits, a note for users of the full SurrealDB-ORM), seven rows of the "ORM behaviour:
51
+ SurrealDB 2.x vs 3.x" table and one of the embedded engine's, and the example notebook
52
+ `examples/v0.38.0_migration_system.ipynb`.
53
+
54
+ ### Changed
55
+
56
+ - `generate_models_from_db()` skips the tracking table `_surreal_orm_migrations`, with a comment
57
+ line in the generated module's header.
58
+ - `DatabaseIntrospector.introspect()` reads the applied migrations' names into
59
+ `SchemaState.applied_migrations` when the database has the tracking table.
60
+ - The README sentences of sections 31 to 36 that promised the migrations "with v0.38.0" now point
61
+ to section 39; section 35 says how to remove a clause a model no longer declares.
62
+
63
+ ### Notes
64
+
65
+ - **`migrate()` and `rollback()` read the database's schema before any change** (`INFO FOR DB`
66
+ and `INFO FOR TABLE`), replay the migrations over it and render every statement from it, so
67
+ that nothing is applied when one of them would be refused, and a table made by
68
+ `define_table()` before any migration can be altered by one. A session refused `INFO FOR DB`
69
+ gets `SurrealDbAuthenticationError` before anything is applied. `fake=True`, `upgrade()` and
70
+ `get_migration_status()` read no schema.
71
+ - **Server lines**: a full-text `CreateIndex` writes `FULLTEXT` on SurrealDB 3.x and `SEARCH` on
72
+ 2.x and the embedded engine. On 2.x and the embedded engine an `any` column of a `SCHEMAFULL`
73
+ table is written `FLEXIBLE`, also in the redefinitions an `AlterTable` that makes a table
74
+ `SCHEMAFULL` writes in the same transaction, so their object values are kept (3.x keeps them
75
+ without it); `DefineEvent(async_mode=True)`, `DefineAccess(with_refresh=True)` and `COMPUTED`
76
+ fields raise `SurrealDbError` before any change. `AddField(reference=True)` is left to the
77
+ server (2.x refuses it unless `record_references` is enabled). A `RemoveAnalyzer` of an
78
+ analyzer an index still uses and a `DropTable` of a table a view reads raise `ValueError` before
79
+ any change on every line.
80
+ - **Deviations from the full ORM**: a migration that defines analyzers commits them first, in a
81
+ transaction of their own (SurrealDB builds an index with the committed analyzer only), and
82
+ restores the definition the database held if the rest fails; `MigrationStatementError` names
83
+ the migration, the operation and SurrealDB's reason, never the statement. The diff of a state
84
+ built from models carries what a model leaves to the database (an absent key never removes a
85
+ stored clause, as with `define_table()`): remove a clause with an `AlterTable`/`AlterField`
86
+ written by hand; a field the model no longer declares is removed by the `DropField` that
87
+ `makemigrations(drop_missing=True)` writes. A diff between two states read from databases or
88
+ migrations compares every clause.
89
+ - **Migration files are Python code**, executed when loaded: point `MigrationExecutor` and
90
+ `makemigrations()` at the application's own directory only. Expressions, rules, view queries,
91
+ event and function bodies, `RawSQL` and `DataMigration` SQL are trusted application code,
92
+ embedded as written: never build an operation from user input.
93
+ - **Deferred**: the CLI (`surreal-orm-lite makemigrations`, `migrate`, `rollback`…) to v0.39.0;
94
+ stored functions declared on models and their diff (the rest of #276); `DefineBearerAccess`,
95
+ `DefineApi` and the GraphQL config on SurrealDB 3.x; `CreateIndex(concurrently=True)`; squashing
96
+ migrations; a non-atomic mode; field `ASSERT`, `READONLY`, permissions and comment declared on
97
+ models; `define_table()` keeping a stored `DEFAULT ALWAYS`; a `schema_diff()` option listing the
98
+ clauses a model leaves to the database.
99
+ - Same code on SurrealDB 2.7.0, 3.3.4 and the embedded engine (3.1.5 retro), with no test skipped
100
+ on a supported line.
101
+
8
102
  ## [0.37.7] - 2026-10-28
9
103
 
10
104
  Follow-up to the review of v0.37.0 (#320): a write the ORM refuses before it reaches the database