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

Fix Analytic orderBy and partitionBy to follow the SQL documentation #4602

Merged
merged 8 commits into from Aug 30, 2021
Merged

Fix Analytic orderBy and partitionBy to follow the SQL documentation #4602

merged 8 commits into from Aug 30, 2021

Conversation

wolfcomp
Copy link
Contributor

@wolfcomp wolfcomp commented Aug 2, 2021

This is a little annoyance I found while writing query calls using rowNumber as the typescript types shows you are allowed to do this but if you try to use an array of objects the SQL request fail with column ?? does not exist where ?? is the array of objects columnized.

This change is required to do more advanced `row_number,dense_rank, or rank` without doing weird workarounds, as you are not allowed to change the sorting order with the current behavior being ascending only.
@kibertoad
Copy link
Collaborator

Thank you for your contribution! Could you please add integration test for this?

@kibertoad
Copy link
Collaborator

@wolfcomp Can I help you with writing a test?

@wolfcomp
Copy link
Contributor Author

Currently writing the tests. Im also adding it into the partition by statement at the same time, as they use the exact same operations in the SQL documentation.

@wolfcomp wolfcomp changed the title Fix Analytic orderBy to follow the normal orderBy logic Fix Analytic orderBy and partitionBy to follow the SQL documentation Aug 20, 2021
get to many test errors due to not being connected to a database
@wolfcomp
Copy link
Contributor Author

@kibertoad if you could start the workflows believe it should work as i cant see it in my terminal window due to me not being able to setup sql server connections on the network im on currently

@wolfcomp
Copy link
Contributor Author

wolfcomp commented Aug 20, 2021

Im unsure to why its saying that the formatter is undefined for columnize as the ones that fails seems to have the formatter set.
@kibertoad if you could take a closer look at it i would appreciate it.

@kibertoad
Copy link
Collaborator

formater -> formatter

@wolfcomp
Copy link
Contributor Author

🤦

@wolfcomp
Copy link
Contributor Author

Now it should work surprised that I haven't had any errors my self.

@wolfcomp
Copy link
Contributor Author

Actually there seems to still be an error as in the project that I use this I did function and not object assign on the parameter.

@wolfcomp
Copy link
Contributor Author

@kibertoad now it should all be fixed from what I can see in my terminal window

@@ -7854,6 +7854,29 @@ describe('QueryBuilder', () => {
);
});

it('row_number with object', function () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you also add an integration test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try to look into it, haven't really written integration tests before, probably will just copy one of the other ones and get it to fit the function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kibertoad after looking through the test/integration folder, I can't find anything previously for rowNumber, denseRank, rank in any of the files, so I'm unsure of how I should do it in that case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are right, we only have unit tests for analytic functions now

@kibertoad
Copy link
Collaborator

@wolfcomp Are TS types correct now? Could you add a tsd test for this case?

@wolfcomp
Copy link
Contributor Author

wolfcomp commented Aug 23, 2021

I can check if the ts files are correct if not correct them fast

@wolfcomp
Copy link
Contributor Author

There seems to be no tsd tests for analytic functions at all from what I can find.

@wolfcomp
Copy link
Contributor Author

@kibertoad this is what the best I can do from what I can find in the files when it comes to already existing code for testing and documenting knex/documentation#333 the added and corrected functionality

@kibertoad kibertoad merged commit 4c79ac1 into knex:master Aug 30, 2021
@kibertoad
Copy link
Collaborator

Released in 0.95.11

@wolfcomp wolfcomp deleted the patch-1 branch September 5, 2021 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants