surrealengine 0.3.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.
- surrealengine-0.3.2/CHANGES.md +194 -0
- surrealengine-0.3.2/LICENSE +21 -0
- surrealengine-0.3.2/MANIFEST.in +6 -0
- surrealengine-0.3.2/PKG-INFO +1095 -0
- surrealengine-0.3.2/README.md +1060 -0
- surrealengine-0.3.2/pyproject.toml +49 -0
- surrealengine-0.3.2/setup.cfg +4 -0
- surrealengine-0.3.2/src/surrealengine/__init__.py +226 -0
- surrealengine-0.3.2/src/surrealengine/aggregation.py +519 -0
- surrealengine-0.3.2/src/surrealengine/base_query.py +1011 -0
- surrealengine-0.3.2/src/surrealengine/connection.py +2205 -0
- surrealengine-0.3.2/src/surrealengine/datagrid_api.py +234 -0
- surrealengine-0.3.2/src/surrealengine/document.py +3019 -0
- surrealengine-0.3.2/src/surrealengine/document_update.py +311 -0
- surrealengine-0.3.2/src/surrealengine/exceptions.py +87 -0
- surrealengine-0.3.2/src/surrealengine/expr.py +456 -0
- surrealengine-0.3.2/src/surrealengine/fields/__init__.py +37 -0
- surrealengine-0.3.2/src/surrealengine/fields/additional.py +319 -0
- surrealengine-0.3.2/src/surrealengine/fields/base.py +231 -0
- surrealengine-0.3.2/src/surrealengine/fields/collection.py +248 -0
- surrealengine-0.3.2/src/surrealengine/fields/datetime.py +373 -0
- surrealengine-0.3.2/src/surrealengine/fields/geometry.py +108 -0
- surrealengine-0.3.2/src/surrealengine/fields/id.py +110 -0
- surrealengine-0.3.2/src/surrealengine/fields/reference.py +396 -0
- surrealengine-0.3.2/src/surrealengine/fields/scalar.py +386 -0
- surrealengine-0.3.2/src/surrealengine/fields/specialized.py +1513 -0
- surrealengine-0.3.2/src/surrealengine/graph.py +160 -0
- surrealengine-0.3.2/src/surrealengine/logging.py +128 -0
- surrealengine-0.3.2/src/surrealengine/materialized_view.py +615 -0
- surrealengine-0.3.2/src/surrealengine/pagination.py +53 -0
- surrealengine-0.3.2/src/surrealengine/query/__init__.py +7 -0
- surrealengine-0.3.2/src/surrealengine/query/base.py +1095 -0
- surrealengine-0.3.2/src/surrealengine/query/descriptor.py +709 -0
- surrealengine-0.3.2/src/surrealengine/query/relation.py +537 -0
- surrealengine-0.3.2/src/surrealengine/query_expressions.py +371 -0
- surrealengine-0.3.2/src/surrealengine/record_id_utils.py +326 -0
- surrealengine-0.3.2/src/surrealengine/relation_update.py +131 -0
- surrealengine-0.3.2/src/surrealengine/schema.py +202 -0
- surrealengine-0.3.2/src/surrealengine/schemaless.py +1158 -0
- surrealengine-0.3.2/src/surrealengine/signals.py +56 -0
- surrealengine-0.3.2/src/surrealengine/surrealql.py +134 -0
- surrealengine-0.3.2/src/surrealengine.egg-info/PKG-INFO +1095 -0
- surrealengine-0.3.2/src/surrealengine.egg-info/SOURCES.txt +44 -0
- surrealengine-0.3.2/src/surrealengine.egg-info/dependency_links.txt +1 -0
- surrealengine-0.3.2/src/surrealengine.egg-info/requires.txt +14 -0
- surrealengine-0.3.2/src/surrealengine.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# SurrealEngine Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the SurrealEngine project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Enhanced
|
|
11
|
+
- **Field Improvements**: Major enhancements to specialized field types for better validation, performance, and functionality
|
|
12
|
+
- **URLField**: Complete rewrite with urllib integration for robust URL validation and component access
|
|
13
|
+
- Added URL component properties: `.scheme`, `.host`, `.port`, `.path`, `.query`, `.fragment`, `.netloc`
|
|
14
|
+
- Added query parameter helpers: `get_query_params()` and `get_query_param()`
|
|
15
|
+
- Added utility methods: `is_secure()` and `get_base_url()`
|
|
16
|
+
- Support for host-only URLs with automatic scheme addition (e.g., "example.com" → "https://example.com")
|
|
17
|
+
- Configurable allowed schemes and default scheme settings
|
|
18
|
+
- **EmailField**: Improved email validation with more comprehensive regex pattern
|
|
19
|
+
- Enhanced regex pattern allows more valid email characters and formats following RFC standards
|
|
20
|
+
- Added additional validation checks for @ symbol count, empty local/domain parts, and domain structure
|
|
21
|
+
- **DecimalField**: Fixed precision loss issues in database operations
|
|
22
|
+
- Database values now stored as strings to preserve exact decimal precision
|
|
23
|
+
- Proper handling of Decimal objects in `to_db()` and `from_db()` methods
|
|
24
|
+
- **IPAddressField**: Fixed validation bug with non-numeric IPv4 octets
|
|
25
|
+
- Added proper error handling for non-numeric octets in IPv4 validation
|
|
26
|
+
- Improved error messages for different validation failure scenarios
|
|
27
|
+
- **BytesField**: Enhanced with comprehensive file-like interface and optimized performance
|
|
28
|
+
- **BytesFieldWrapper**: New file-like wrapper class providing standard Python file operations (read, write, seek, tell, flush, close)
|
|
29
|
+
- **Context Manager Support**: Full `with` statement compatibility for safe resource handling
|
|
30
|
+
- **File Operations**: Direct file loading/saving with `load_from_file()` and `save_to_file()` methods
|
|
31
|
+
- **Stream Operations**: Stream copying with `copy_to_stream()` and `copy_from_stream()` for large file handling
|
|
32
|
+
- **Metadata Support**: File metadata including filename, content_type, and custom metadata dictionary
|
|
33
|
+
- **Text Operations**: Convenient `read_text()` and `write_text()` methods with encoding support
|
|
34
|
+
- **Size Limits**: Configurable maximum size validation with proper error handling
|
|
35
|
+
- **Database Integration**: Seamless conversion to/from SurrealDB bytes format with base64 encoding
|
|
36
|
+
- **Performance Optimization**: Moved `base64` import from method level to module level
|
|
37
|
+
- **Memory Efficient**: Chunked reading/writing for large files to manage memory usage
|
|
38
|
+
- **Developer Experience**: Intuitive API matching standard Python file objects for easy adoption
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- Fixed IPv4 address validation crash when octets contain non-numeric values
|
|
42
|
+
- Fixed decimal precision loss when converting between Python Decimal and database storage
|
|
43
|
+
- Improved email validation to accept more RFC-compliant email addresses
|
|
44
|
+
|
|
45
|
+
## [0.3.0] - 2025-09-01
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
- Expression and query building
|
|
49
|
+
- Expr is now a single class with a working CASE builder: `Expr.case().when(...).else_(...).alias(...)`
|
|
50
|
+
- `Expr.var(name)` for `$vars` and `Expr.raw(...)` for trusted fragments
|
|
51
|
+
- String functions aligned with SurrealDB v2: `string::starts_with`, `string::ends_with`, `string::contains`, `string::matches`
|
|
52
|
+
- Escaping utilities
|
|
53
|
+
- Public `escape_literal` and `escape_identifier`; builders use these consistently
|
|
54
|
+
- Aggregation and materialized views
|
|
55
|
+
- AggregationPipeline: response normalization (returns list of row dicts), safe escaping in `match()`/`having()`, and injects `GROUP BY`/`GROUP ALL` when needed
|
|
56
|
+
- Materialized functions updated for v2: replaced `array::collect` with `array::group`; hardened `Distinct`, `GroupConcat` for scalar inputs; `DistinctCountIf` now uses `array::len(array::group(IF cond THEN [field] ELSE [] END))`
|
|
57
|
+
- Connection and observability
|
|
58
|
+
- ContextVar‑backed per‑task default connection: `set_default_connection` / `get_default_connection`
|
|
59
|
+
- Connection pooling with validation, idle pruning, retries/backoff
|
|
60
|
+
- OperationQueue with backpressure policies (block | drop_oldest | error) and metrics
|
|
61
|
+
- Optional OpenTelemetry spans around queries/transactions (enabled if OTEL is installed)
|
|
62
|
+
- Example script: `example_scripts/connection_and_observability_example.py`
|
|
63
|
+
- Graph and live updates
|
|
64
|
+
- QuerySet.traverse(path, max_depth=None, unique=True) to project graph traversals
|
|
65
|
+
- QuerySet.live(...): async generator for LIVE subscriptions (requires direct async ws connection)
|
|
66
|
+
- Example script: `example_scripts/graph_and_live_example.py`
|
|
67
|
+
- RelationDocument helpers
|
|
68
|
+
- `RelationDocument.find_by_in_documents(...)` and sync variant for batch inbound lookups
|
|
69
|
+
- Document/Relation updates
|
|
70
|
+
- Added `update()` and `update_sync()` on Document and RelationDocument for partial updates without data loss
|
|
71
|
+
|
|
72
|
+
### Changed
|
|
73
|
+
- Centralized escaping in BaseQuerySet, AggregationPipeline, and Expr; removed ad‑hoc json.dumps usage for literals
|
|
74
|
+
- SurrealQL builder ensures `FETCH` is emitted as the last clause to avoid parse errors
|
|
75
|
+
- LIVE subscription path: replaced debug print statements with logger.debug to avoid leaking to stdout and to integrate with standard logging
|
|
76
|
+
- Docstring improvements across key APIs (e.g., QuerySet.live()) for richer IDE hints
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
- BaseQuerySet condition building now uses `escape_literal` consistently, including URL handling and arrays; preserves unquoted RecordIDs in INSIDE/NOT INSIDE arrays
|
|
80
|
+
- Materialized array functions migrated to v2 semantics; `DistinctCountIf` produces correct distinct counts without function argument errors
|
|
81
|
+
- Schema regex assertions now use `string::matches($value, pattern)` with proper literal escaping
|
|
82
|
+
- AggregationPipeline results are normalized (no more `'str'.get` errors in examples)
|
|
83
|
+
- Correct formatting for INSIDE/NOT INSIDE arrays containing RecordIDs (record ids unquoted)
|
|
84
|
+
- Document.save() automatically uses `update()` for RelationDocument to prevent unintended field removal
|
|
85
|
+
- Fixed TypeError in document update isinstance check
|
|
86
|
+
|
|
87
|
+
### Notes
|
|
88
|
+
- LIVE queries currently require a direct async websocket client (pooling client does not support LIVE)
|
|
89
|
+
- `returning=` is supported on `QuerySet.update(...)`; other mutations may follow in a future release
|
|
90
|
+
|
|
91
|
+
## [0.2.1] - 2025-07-02
|
|
92
|
+
|
|
93
|
+
### Added
|
|
94
|
+
- **Query Expression System**: Advanced query building with Q objects and QueryExpression
|
|
95
|
+
- **Q objects** for complex boolean logic supporting AND (&), OR (|), and NOT (~) operations
|
|
96
|
+
- **QueryExpression class** for comprehensive query building with FETCH, ORDER BY, GROUP BY, LIMIT, and START clauses
|
|
97
|
+
- **objects(query) syntax** - Alternative to filter() allowing direct query object passing: `User.objects(Q(active=True))`
|
|
98
|
+
- **filter(query) enhancement** - Now accepts Q objects and QueryExpressions in addition to kwargs
|
|
99
|
+
- **Raw query support** with `Q.raw()` for custom SurrealQL WHERE clauses
|
|
100
|
+
- **FETCH integration** - QueryExpression with FETCH automatically dereferences related documents
|
|
101
|
+
- **Django-style operators** - Support for field__operator syntax (gt, lt, gte, lte, ne, in, contains, startswith, endswith, regex)
|
|
102
|
+
- **Method chaining** - Full compatibility with existing queryset methods (limit, order_by, fetch, etc.)
|
|
103
|
+
- **Synchronous support** - All query expression features work with both async and sync operations
|
|
104
|
+
|
|
105
|
+
### Fixed
|
|
106
|
+
- **String function compatibility** - Updated to use correct SurrealDB v2.x string function names (`string::starts_with` instead of `string::startsWith`, `string::ends_with` instead of `string::endsWith`)
|
|
107
|
+
|
|
108
|
+
### Added (Continued)
|
|
109
|
+
- **DataGrid API Support**: Comprehensive frontend integration for data table libraries
|
|
110
|
+
- Efficient SurrealDB query optimization replacing Python-based filtering with database-native operations
|
|
111
|
+
- Support for BootstrapTable.js format (maintaining backward compatibility with existing APIs)
|
|
112
|
+
- DataTables.js parameter conversion and response formatting
|
|
113
|
+
- Pagination, sorting, filtering, and search functionality optimized at the database level
|
|
114
|
+
- `get_grid_data()` and `get_grid_data_sync()` helper functions for easy route integration
|
|
115
|
+
- `DataGridQueryBuilder` class for building complex filtered queries
|
|
116
|
+
- Parameter conversion utilities: `parse_datatables_params()` and `format_datatables_response()`
|
|
117
|
+
- Performance benefits: Only fetch required data, leverage SurrealDB indexes, reduce memory usage
|
|
118
|
+
- Drop-in replacement for existing route logic - reduces 50+ lines of filtering code to a single function call
|
|
119
|
+
|
|
120
|
+
## [0.2.0] - 2024-06-28
|
|
121
|
+
|
|
122
|
+
### Added
|
|
123
|
+
- Implemented advanced connection management features:
|
|
124
|
+
- Connection pooling with configurable pool size, connection reuse, validation, and cleanup
|
|
125
|
+
- Integration of connection pools with Document models for seamless use in async applications
|
|
126
|
+
- Connection timeouts and retries with exponential backoff
|
|
127
|
+
- Automatic reconnection with event-based triggers and operation queuing
|
|
128
|
+
- Connection string parsing with support for connection options
|
|
129
|
+
- Pagination support across all query methods with `page(number, size)` method
|
|
130
|
+
- Made dependencies optional: signals (blinker) and jupyter (notebook) can now be installed separately
|
|
131
|
+
- Added `PaginationResult` class for enhanced pagination with metadata
|
|
132
|
+
- Added new field types: EmailField, URLField, IPAddressField, SlugField, ChoiceField
|
|
133
|
+
- Added proper logging system with SurrealEngineLogger class
|
|
134
|
+
- Added native SurrealDB type support with LiteralField and RangeField
|
|
135
|
+
- Enhanced SetField to ensure uniqueness during validation
|
|
136
|
+
- Added TimeSeriesField for time series data with metadata support
|
|
137
|
+
- Added materialized views support with MaterializedView class and Document.create_materialized_view method
|
|
138
|
+
- Enhanced materialized views with support for aggregation functions (count, mean, sum, min, max, array_collect) and custom field selection
|
|
139
|
+
- Added `get_raw_query()` method to BaseQuerySet to get the raw query string without executing it, allowing for manual execution or modification of queries
|
|
140
|
+
- Added `execute_raw_query()` and `execute_raw_query_sync()` methods to MaterializedView to execute raw queries against materialized views
|
|
141
|
+
- Added field-level indexing with `indexed`, `unique`, `search`, and `analyzer` parameters
|
|
142
|
+
- Added support for multi-field indexes with the `index_with` parameter
|
|
143
|
+
- Added aggregation pipelines with the `AggregationPipeline` class for complex data transformations
|
|
144
|
+
- Added additional aggregation functions: Median, StdDev, Variance, Percentile, Distinct, GroupConcat
|
|
145
|
+
- Added automatic reference resolution with `Document.get(dereference=True)` and `Document.resolve_references()` methods
|
|
146
|
+
- Added JOIN-like operations with `QuerySet.join()` method for efficient retrieval of referenced documents
|
|
147
|
+
- Enhanced RelationField with `get_related_documents()` method for bidirectional relation navigation
|
|
148
|
+
- **PERFORMANCE IMPROVEMENT**: Updated all reference/dereference code to use SurrealDB's native FETCH clause instead of manual resolution:
|
|
149
|
+
- `ReferenceField.from_db()` now handles fetched documents automatically
|
|
150
|
+
- `RelationField.from_db()` now handles fetched relations automatically
|
|
151
|
+
- `Document.resolve_references()` uses FETCH queries for efficient bulk resolution
|
|
152
|
+
- `Document.get()` with `dereference=True` uses FETCH for single-query reference resolution
|
|
153
|
+
- `QuerySet.join()` methods use FETCH clauses internally for better performance
|
|
154
|
+
- Maintains full backward compatibility with fallback to manual resolution if FETCH fails
|
|
155
|
+
- **MAJOR PERFORMANCE ENHANCEMENT**: Implemented comprehensive query performance optimizations:
|
|
156
|
+
- **Auto-optimization for `id__in` filters**: Automatically converts `filter(id__in=[...])` to direct record access syntax `SELECT * FROM user:id1, user:id2, user:id3` for up to 3.4x faster queries
|
|
157
|
+
- **New convenience methods**: Added `get_many(ids)` and `get_range(start_id, end_id)` for optimized bulk record retrieval using direct record access and range syntax
|
|
158
|
+
- **Smart filter optimization**: Automatic detection of ID range patterns (`id__gte` + `id__lte`) and conversion to optimized range queries `SELECT * FROM table:start..=end`
|
|
159
|
+
- **Developer experience tools**:
|
|
160
|
+
- `explain()` and `explain_sync()` methods for query execution plan analysis
|
|
161
|
+
- `suggest_indexes()` method for intelligent index recommendations based on query patterns
|
|
162
|
+
- **Optimized bulk operations**: Enhanced `update()` and `delete()` methods with direct record access for bulk ID operations, improving performance for large datasets
|
|
163
|
+
- **Universal ID support**: All optimizations work seamlessly with both auto-generated IDs and custom IDs, maintaining backward compatibility
|
|
164
|
+
|
|
165
|
+
### Changed
|
|
166
|
+
- Updated README.md with instructions for installing optional dependencies
|
|
167
|
+
- Improved pagination ergonomics with the `page(number, size)` method
|
|
168
|
+
- Marked "Implement schema registration with SurrealDB" as completed in tasks.md
|
|
169
|
+
- Removed JSONField and replaced it with DictField for better functionality and consistency
|
|
170
|
+
- Refactored fields.py into a directory structure with separate modules for better organization and maintainability
|
|
171
|
+
|
|
172
|
+
### Fixed
|
|
173
|
+
- Fixed pagination support to work with all query methods, not just filter()
|
|
174
|
+
- Enhanced ReferenceField to properly handle RecordID objects
|
|
175
|
+
- Fixed DictField nested field access in queries using double underscore syntax (e.g., `settings__theme="dark"`)
|
|
176
|
+
- Added support for nested fields in DictFields when using schemafull tables
|
|
177
|
+
- Fixed IPAddressField to properly handle the 'version' parameter for backward compatibility
|
|
178
|
+
- Fixed issue with docstring comments in create_table method causing parsing errors
|
|
179
|
+
- Removed debug print statements and commented-out code for cleaner codebase
|
|
180
|
+
- **CRITICAL FIX**: Fixed ID formatting issue in upsert operations where numeric string IDs like "testdoc:123" were being stored incorrectly, causing retrieval failures
|
|
181
|
+
|
|
182
|
+
## [0.1.0] - 2023-05-12
|
|
183
|
+
|
|
184
|
+
### Added
|
|
185
|
+
- Initial release of SurrealEngine
|
|
186
|
+
- Basic document model with field validation
|
|
187
|
+
- Query functionality with filtering and pagination
|
|
188
|
+
- Schemaless API for flexible database access
|
|
189
|
+
- Support for both synchronous and asynchronous operations
|
|
190
|
+
- Connection management with connection registry
|
|
191
|
+
- Transaction support
|
|
192
|
+
- Relation management with graph traversal
|
|
193
|
+
|
|
194
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 SurrealEngine Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|