Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lveillard
Copy link
Member

@lveillard lveillard commented Jul 3, 2024

πŸš€ This description was created by Ellipsis for commit 6f7bfa9

Summary:

Refactored mutation machine to separate TQL and SurrealDB logic, enhancing maintainability and error handling.

Key points:

  • Refactored mutation machine to separate TQL logic into src/stateMachine/mutation/tql/machine.ts.
  • Introduced SurrealDB mutation machine in src/stateMachine/mutation/surql/machine.ts.
  • Updated MachineContext in src/stateMachine/mutation/mutationMachine.ts to remove TQL-specific fields.
  • Added runTypeDbMutationMachine and runSurrealDbMutationMachine in src/stateMachine/mutation/mutationMachine.ts.
  • Enhanced error handling and state transitions for TQL and SurrealDB mutation machines.
  • Updated buildTQLMutation in src/stateMachine/mutation/tql/build.ts for validation and error handling.
  • Updated buildSURQLMutation in src/stateMachine/mutation/surql/build.ts for validation and error handling.
  • Modified src/stateMachine/query/queryMachine.ts to handle new mutation machines.
  • Added new test scripts in package.json for SurrealDB mutations.
  • Updated tests/unit/mutations/basic.ts to include tests for new mutation structure.

Generated with ❀️ by ellipsis.dev

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to b7b7194 in 28 seconds

More details
  • Looked at 359 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_3FKcWeFCV19yohj6


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with πŸ‘ / πŸ‘Ž feedback, review rules, user-specific overrides, quiet mode, and more.

}

throw new Error(`Unsupported DB "${a.db}"`);
throw new Error(`Unsupported DB "${JSON.stringify(a, null, 2)}"`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message on line 137 could potentially expose sensitive information by converting the adapter object to a string. Consider revising the error message to be more generic or to only include necessary details.

Suggested change
throw new Error(`Unsupported DB "${JSON.stringify(a, null, 2)}"`);
throw new Error(`Unsupported DB type: ${a.db}`);

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ Looks good to me! Incremental review on 4e106d6 in 46 seconds

More details
  • Looked at 611 lines of code in 11 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. src/stateMachine/mutation/surql/run.ts:12
  • Draft comment:
    Consider removing or securing the logging of sensitive data in production environments to prevent potential data exposure.
  • Reason this comment was not posted:
    Confidence of 0% on close inspection, compared to threshold of 50%.

Workflow ID: wflow_NtZN2sXWNI2ViOHN


You can customize Ellipsis with πŸ‘ / πŸ‘Ž feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on 160fdf8 in 1 minute and 27 seconds

More details
  • Looked at 1428 lines of code in 19 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_VDfMMvPtQoR050pY


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with πŸ‘ / πŸ‘Ž feedback, review rules, user-specific overrides, quiet mode, and more.

const fields = [...dataFields, ...linkFields, ...roleFields];
const fieldsString = fields.length ? `SET ${fields.join(', ')}` : '';

return `{ LET ${$var} = ${op} ONLY ${tableName}:⟨${idValue}⟩ ${fieldsString} RETURN {${restString}} as input, $before as before, $after as after, {${metaString},'$id': meta::id(id),'id': meta::id(id)} as meta, id as sid; CREATE ONLY Delta SET bzId = ⟨${block.$bzId}⟩, result = ${$var}; ${level !== 0 ? `RETURN ${$var}.sid` : ''}; }` as string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RETURN statement should be outside of the LET block to ensure it is part of the main query flow. This is crucial for the correct execution of the SurrealDB query.

Suggested change
return `{ LET ${$var} = ${op} ONLY ${tableName}:⟨${idValue}⟩ ${fieldsString} RETURN {${restString}} as input, $before as before, $after as after, {${metaString},'$id': meta::id(id),'id': meta::id(id)} as meta, id as sid; CREATE ONLY Delta SET bzId = ⟨${block.$bzId}⟩, result = ${$var}; ${level !== 0 ? `RETURN ${$var}.sid` : ''}; }` as string;
return `{ LET ${$var} = ${op} ONLY ${tableName}:⟨${idValue}⟩ ${fieldsString} RETURN {${restString}} as input, $before as before, $after as after, {${metaString},'$id': meta::id(id),'id': meta::id(id)} as meta, id as sid; CREATE ONLY Delta SET bzId = ⟨${block.$bzId}⟩, result = ${$var}; } RETURN ${$var}.sid;` as string;

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ Looks good to me! Incremental review on bb784bd in 1 minute and 13 seconds

More details
  • Looked at 1418 lines of code in 9 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. src/adapters/surrealDB/filters/filters.ts:6
  • Draft comment:
    The parseFilter function is well-implemented with comprehensive handling of various filter types and recursive transformation for nested filters. It correctly adapts filters to the syntax and capabilities of SurrealDB, ensuring accurate query operations.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The parseFilter function in filters.ts is designed to transform filters from one format to another, specifically for use with SurrealDB. It handles various logical operators and ensures that filters are correctly formatted for SurrealDB's query language. The function recursively handles nested filters and applies transformations such as renaming $not to $! and handling $id specifically to use SurrealDB's meta::id(id) syntax. The function also handles different field types, including data fields, link fields, and role fields, ensuring that the correct filter format is used based on the field type and schema information.

The function is complex due to its recursive nature and the variety of filter transformations it supports. It is crucial for ensuring that filters are correctly applied in queries to SurrealDB, which can affect the accuracy and security of data retrieval in applications using this database.

Workflow ID: wflow_MHDVn0dnBOylIoVx


You can customize Ellipsis with πŸ‘ / πŸ‘Ž feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ Looks good to me! Incremental review on 1b66aef in 49 seconds

More details
  • Looked at 4152 lines of code in 34 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. tests/unit/queries/query.ts:1592
  • Draft comment:
    The test case 'i2[inherited, attributes]' is marked as TODO{TS}, but it seems to be implemented and working. Consider removing the TODO marker.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The test case 'i2[inherited, attributes]' is marked as TODO{TS}, indicating it is not yet implemented or is expected to fail. However, the test case is already implemented and seems to be checking for inherited attributes correctly. The TODO marker should be removed to reflect the current state of the test.

Workflow ID: wflow_djJHbhRHDghsO555


You can customize Ellipsis with πŸ‘ / πŸ‘Ž feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ Looks good to me! Incremental review on c996e81 in 49 seconds

More details
  • Looked at 381 lines of code in 10 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. src/helpers.ts:366
  • Draft comment:
    Using console.warn instead of throw new Error for schema issues might lead to silent failures or unnoticed issues in production. Consider handling these cases explicitly.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is relevant to a change made in the diff, specifically the replacement of throw new Error with console.warn. This change could indeed lead to issues being less noticeable, which is a valid concern. The comment is actionable as it suggests reconsidering the use of console.warn.
    The comment could be seen as speculative since it assumes that the change will lead to silent failures without knowing the context of how warnings are handled in the application.
    The concern about silent failures is valid, especially in production environments where warnings might not be logged or monitored as closely as errors.
    Keep the comment as it addresses a potential issue introduced by the code change and is actionable.
2. src/helpers.ts:406
  • Draft comment:
    Using console.warn instead of throw new Error for schema issues might lead to silent failures or unnoticed issues in production. Consider handling these cases explicitly.
  • Reason this comment was not posted:
    Marked as duplicate.
3. src/stateMachine/mutation/bql/stringify.ts:80
  • Draft comment:
    Using console.warn instead of throw new Error for schema issues might lead to silent failures or unnoticed issues in production. Consider handling these cases explicitly.
  • Reason this comment was not posted:
    Marked as duplicate.
4. src/stateMachine/mutation/bql/parse.ts:462
  • Draft comment:
    Using console.warn instead of throw new Error for schema issues might lead to silent failures or unnoticed issues in production. Consider handling these cases explicitly.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_VnTh5N2FhyjlZFW0


You can customize Ellipsis with πŸ‘ / πŸ‘Ž feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ Looks good to me! Incremental review on 6f7bfa9 in 14 seconds

More details
  • Looked at 137 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. changelog.md:5
  • Draft comment:
    The changelog entry for version 0.11.0 is vague. Consider providing more details about the changes, such as the refactoring of the mutation machine and the introduction of the SurrealDB mutation machine.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The changelog entry for version 0.11.0 is missing a detailed description of the changes made in this PR. It only mentions 'Working queries and basic mutations for surrealDB', which is vague.

Workflow ID: wflow_keA3LeimRlyi3xws


You can customize Ellipsis with πŸ‘ / πŸ‘Ž feedback, review rules, user-specific overrides, quiet mode, and more.

@lveillard lveillard merged commit b32a08d into main Sep 1, 2024
@lveillard lveillard deleted the feat-suql-mutations branch September 1, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants