feat:surrealDB queries 39-23
Sweep: PR Review
This pull request enhances SurrealDB query handling and introduces benchmark testing.
The main change involved modifying how $filter mappings are processed. The $filterProcessed property was removed from various types and functions, and the mapFilterKeys function was relocated to be used exclusively within TQL (Typed Query Language) queries. This ensures that $filter mappings are now only applied in TQL contexts, simplifying the BQL (Basic Query Language) processing logic.
Additionally, a new benchmark test was added. The bench.sh script was created to automate the setup and teardown of a SurrealDB Docker container for running these benchmarks. This script initializes the database, imports schema and data, and executes the benchmarks using npx vitest bench.
Minor changes included updating test descriptions and filter conditions to improve clarity and accuracy. For example, test cases were renamed to better reflect their purpose, such as changing "ef6[entity,filter] - $filter by unique field" to "ef6[entity,filter,id] - $filter by id in filter".
The changelog was updated to reflect these changes, documenting the new version 0.10.13 and the addition of benchmark tests and SurrealDB query enhancements.
Sweep Found These Issues
src/adapters/surrealDB/types/base.ts
- The removal of the
$filterProcessedproperty may cause functional issues in parts of the codebase that rely on this property to determine the processing state of filters.
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/src%2Fadapters%2FsurrealDB%2Ftypes%2Fbase.ts#L16-L19 View Diff
src/stateMachine/query/bql/enrich.ts
- Directly assigning
field.$filterwithout transformation increateRoleFieldmay lead to incorrect filter application if the schema requires key mapping.
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/src%2FstateMachine%2Fquery%2Fbql%2Fenrich.ts#L305-L308 View Diff
src/stateMachine/query/tql/build.ts
- The
mapFilterKeysfunction does not handle cases wherethingSchemais null or undefined, which could lead to runtime errors. - The
buildFilterfunction now relies onmapFilterKeys, but there is no error handling ifmapFilterKeysreturns an invalid or unexpected filter structure. - Sweep has identified a redundant function: The new function
mapFilterKeysis redundant as its functionality is already covered byprocessFilterandmapPositiveFilterKeys. - Sweep has identified a redundant function: The new function
mapPositiveFilterKeysis redundant because its functionality is already covered by the existingmapFilterKeysfunction, which callsmapPositiveFilterKeysinternally.
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/src%2FstateMachine%2Fquery%2Ftql%2Fbuild.ts#L295-L315 View Diff
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/src%2FstateMachine%2Fquery%2Ftql%2Fbuild.ts#L327-L336 View Diff
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/src%2FstateMachine%2Fquery%2Ftql%2Fbuild.ts#L295-L315 View Diff
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/src%2FstateMachine%2Fquery%2Ftql%2Fbuild.ts#L318-L324 View Diff
src/types/requests/queries.ts
- The removal of the
$filterProcessedproperty from theEnrichedRoleQuerytype may break existing logic that relies on this property to determine the processing state of a filter.
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/src%2Ftypes%2Frequests%2Fqueries.ts#L118-L120 View Diff
tests/bench.sh
- The script does not handle potential errors from Docker commands, which could lead to silent failures or incomplete setups.
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/tests%2Fbench.sh#L6-L24 View Diff
tests/surrealdb/README.md
- The removal of
tests/surrealdb/README.mdeliminates critical setup and testing instructions, which could hinder developers from properly setting up and running tests for SurrealDB.
https://github.com/Blitzapps/blitz-orm/blob/46a669171ae95cafbe31d77d13b5278c0cbc23cd/tests%2Fsurrealdb%2FREADME.md#L1-L29 View Diff
tests/surrealdb/bench/all.bench.ts
- The
initfunction is used without any error handling, which could lead to unhandled exceptions ifinitfails.
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/tests%2Fsurrealdb%2Fbench%2Fall.bench.ts#L2-L4 View Diff
Potential Issues
Sweep is unsure if these are issues, but they might be worth checking out.
src/stateMachine/query/bql/enrich.ts
- The removal of the
mapFilterKeysfunction means that filter keys will no longer be transformed based on the schema, which could lead to incorrect filter processing if the schema paths differ from the database paths. - The removal of the
mapFilterKeysfunction and its associated logic means that filters will no longer be transformed based on the schema, which could lead to incorrect filter processing.
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/src%2FstateMachine%2Fquery%2Fbql%2Fenrich.ts#L75-L77 View Diff
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/src%2FstateMachine%2Fquery%2Fbql%2Fenrich.ts#L75-L77 View Diff
tests/typedb/bench/all.bench.ts
- The
initfunction is called within the benchmark test without any error handling, which could cause the benchmark to fail ifinitthrows an error.
https://github.com/Blitzapps/blitz-orm/blob/1f80eb4b08d800b38c54658d1918d579c6c5210d/tests%2Ftypedb%2Fbench%2Fall.bench.ts#L2-L4 View Diff
package.json was not reviewed because our filter identified it as typically a non-human-readable or less important file (e.g., dist files, package.json, images). If this is an error, please let us know.
Sweep: Please fix these:
File: tests/bench.sh The script does not handle potential errors from Docker commands, which could lead to silent failures or incomplete setups.
File: tests/surrealdb/bench/all.bench.ts The init function is used without any error handling, which could lead to unhandled exceptions if init fails.
❌ An error occured!
The exception message is:/tmp/cache/repos/Blitzapps/blitz-orm/b4e33ac3c01cd732fc6f5e85ce06c9d85d6107d5b027f9bd249c8c36a2adcc39/feat-surrealdb-queries/tests/surrealdb/README.md does not exist.
The stack trace is:Traceback (most recent call last):
File "/app/sweepai/handlers/on_comment.py", line 277, in on_comment
snippets_modified = [Snippet.from_file(
File "/app/sweepai/handlers/on_comment.py", line 278, in
Please report this on our community forum.
This is an automated message generated by Sweep AI.
Sweep: Please fix these:
File: tests/bench.sh The script does not handle potential errors from Docker commands, which could lead to silent failures or incomplete setups.
File: tests/surrealdb/bench/all.bench.ts The init function is used without any error handling, which could lead to unhandled exceptions if init fails.
Dont explore this file, as it was deleted in this PR, so please dont review it: /tests/surrealdb/README.md
❌ An error occured!
The exception message is:/tmp/cache/repos/Blitzapps/blitz-orm/617a5e3467d60497fb4105c52b112ca8c9cae585007af96beb9801214aaf4f74/feat-surrealdb-queries/tests/surrealdb/README.md does not exist.
The stack trace is:Traceback (most recent call last):
File "/app/sweepai/handlers/on_comment.py", line 277, in on_comment
snippets_modified = [Snippet.from_file(
File "/app/sweepai/handlers/on_comment.py", line 278, in
Please report this on our community forum.
This is an automated message generated by Sweep AI.