-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add random() order support #16964
base: main
Are you sure you want to change the base?
Add random() order support #16964
Conversation
var id = idList.ChildNodes[i].ChildNodes[0]; | ||
|
||
// RANDOM() is a special case where we need to use the dialect's random function. | ||
if (id.ChildNodes[0].Token?.ValueString == "RANDOM") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could work in SQLite & Postgres only, RAND
is the one that works in SQL Server and MySQL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_builder.Append(_dialect.RandomOrderByClause);
But maybe you forgot how sql queries are managed in this feature. Call me if you want a quick refresher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I revisited YesSQL and after I looked to _dialect.RandomOrderByClause
it's fine for me
if (funArgs.Term.Name == "funArgs" && funArgs.ChildNodes.Count == 0) | ||
{ | ||
_builder.Append(_dialect.RandomOrderByClause); | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continue; | |
continue; |
var result = SqlParser.TryParse(sql, _schema, _defaultDialect, _defaultTablePrefix, null, out var rawQuery, out var errors); | ||
Assert.True(result); | ||
Assert.Equal(expectedSql, FormatSql(rawQuery)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var result = SqlParser.TryParse(sql, _schema, _defaultDialect, _defaultTablePrefix, null, out var rawQuery, out var errors); | |
Assert.True(result); | |
Assert.Equal(expectedSql, FormatSql(rawQuery)); | |
// Arrange & Act | |
var result = SqlParser.TryParse(sql, _schema, _defaultDialect, _defaultTablePrefix, null, out var rawQuery, out var errors); | |
// Assert | |
Assert.True(result); | |
Assert.Equal(expectedSql, FormatSql(rawQuery)); |
Fixes #16961