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

OrderBy multiple items give inconsistent queries #2058

Open
KevinAtSesam opened this issue Sep 20, 2023 · 0 comments
Open

OrderBy multiple items give inconsistent queries #2058

KevinAtSesam opened this issue Sep 20, 2023 · 0 comments

Comments

@KevinAtSesam
Copy link

There is some inconsistent behaviour when using the sqls.orderBy syntax

Example current

The code

val sorting: SQLSyntax = (params.sortBy, params.sortDirection) match {
  case (Some("name"), Some("asc"))  => sqls.orderBy(D.name, D.id).asc
  case (Some("name"), Some("desc")) => sqls.orderBy(D.name, D.id).desc
  [...]
}

The SQL statement

ORDER BY device.name, device.id ASC
ORDER BY device.name, device.id DESC

The implicit meaning

ORDER BY device.name ASC, device.id ASC
ORDER BY device.name ASC, device.id DESC

Example broken

val sorting: SQLSyntax = (params.sortBy, params.sortDirection) match {
  case (Some("name"), Some("asc"))  => sqls.orderBy(D.name).asc.orderBy(D.id).asc
  case (Some("name"), Some("desc")) => sqls.orderBy(D.name).desc.orderBy(D.id).desc
  [...]
}

The corrupt SQL statement

ORDER BY device.name ASC, ORDER BY device.id ASC
ORDER BY device.name DESC, ORDER BY device.id DESC

Summary

There is currently no good way to write a multi-orderBy, unless you'll just write it as a string. Ideally, you can define multiple orderBy items who are then processed into one ORDER BY sql statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants