Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move AggregateFunctionsSuggestion to a separate interface, refactor general parser create tests #92

Merged
merged 15 commits into from
Nov 30, 2023

Conversation

NikitaShkaruba
Copy link
Collaborator

Part of #85

@NikitaShkaruba NikitaShkaruba self-assigned this Nov 29, 2023
@NikitaShkaruba NikitaShkaruba changed the title refactor: refactor general parser create tests feat: move AggregateFunctionsSuggestion to a separate interface, refactor general parser create tests Nov 29, 2023
// - 'something [IF NOT EXITS]'
// - 'something IF [NOT EXISTS]'
// - 'something IF NOT [exists]'
// - 'something [IF NOT EXISTS] something2'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All the todos are fine, I'll fix them later

@@ -63,7 +63,7 @@ test('should suggest WHERE columns', () => {
})

test('should suggest WHERE columns when some column conditions already exist', () => {
const parseResult = parseGenericSqlWithoutCursor('DELETE FROM test_table WHERE test_column = 1 AND ');
const parseResult = parseGenericSql('DELETE FROM test_table WHERE test_column = 1 AND ', '');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have cursor, so I've decided to replace the function

@@ -26,6 +26,7 @@ AlterTable
: AlterTableLeftSide PartitionSpec
;

// TODO: support AlterTableRightSide, PartitionSpec will not work for MySQL, PostgreSQL
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't have ALTER TABLE table_name ADD column_name datatype; supported, sadly :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, noticed that..

- A test that checks locations (can be merged with the one above)
- Don't use `foo` or `bar` custom names, always use `test_{object}`, e.g. `SELECT * FROM test_table`, not `SELECT * FROM hehe_haha`. If you need multiple names, use `_{number}` suffix, e.g. `SELECT test_field, test_field_2 FROM test_table;`
- Write all the static tokens in UPPER_CASE, and all the custom variables in lower_case, e.g. `SELECT test_field`
- Always test your statements on errors, and if there's an unexpected error, just add `TODO: fix unhandled error` error
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should I add something else, or is it complete?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's pretty good!


- Each test should only test a granular added piece of logic, and shouldn't test functionality of other's. E.g. if you are using OptionalIfNotExists, you shouldn't test if you get suggestions when writing '', 'IF ', 'IF NOT', just test if `IF NOT EXISTS` is suggesting, and it's enough.
- Each test file should contain
- A test that on full statement for errors
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: extra 'that'

- A test that checks locations (can be merged with the one above)
- Don't use `foo` or `bar` custom names, always use `test_{object}`, e.g. `SELECT * FROM test_table`, not `SELECT * FROM hehe_haha`. If you need multiple names, use `_{number}` suffix, e.g. `SELECT test_field, test_field_2 FROM test_table;`
- Write all the static tokens in UPPER_CASE, and all the custom variables in lower_case, e.g. `SELECT test_field`
- Always test your statements on errors, and if there's an unexpected error, just add `TODO: fix unhandled error` error
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's pretty good!

@@ -26,6 +26,7 @@ AlterTable
: AlterTableLeftSide PartitionSpec
;

// TODO: support AlterTableRightSide, PartitionSpec will not work for MySQL, PostgreSQL
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, noticed that..

@NikitaShkaruba NikitaShkaruba merged commit 08e8c26 into main Nov 30, 2023
3 checks passed
@NikitaShkaruba NikitaShkaruba deleted the json_tests_replacement_2 branch November 30, 2023 10:49
This was referenced Nov 30, 2023
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