Araq / ormin

Ormin -- An ORM for Nim.
MIT License
152 stars 18 forks source link

Incorrect handling of multiple sort keys in "orderby" #30

Closed huaxk closed 4 years ago

huaxk commented 4 years ago
  test "query post with orderby: mulitple key":
    let res = query:
      select post(author, id)
      orderby author, desc(id)
Hint: /home/huaxk/sources/ormin/tests/tforum  [Exec]
/home/huaxk/sources/ormin/ormin/ormin_sqlite.nim(24) prepareStmt
/home/huaxk/sources/ormin/ormin/ormin_sqlite.nim(20) dbError
Error: unhandled exception: no such column: p1.authorp1.id [DbError]
Error: execution of an external program failed: '/home/huaxk/sources/ormin/tests/tforum '
stack trace: (most recent call last)
/tmp/nimblecache/nimscriptapi.nim(165, 16)
/home/huaxk/sources/ormin/ormin_5261.nims(32, 8) testsqliteTask
/home/huaxk/.choosenim/toolchains/nim-1.0.4/lib/system/nimscript.nim(252, 7) exec
/home/huaxk/.choosenim/toolchains/nim-1.0.4/lib/system/nimscript.nim(252, 7) Error: unhandled exception: FAILED: nim c -r tests/tforum [OSError]
       Tip: 2 messages have been suppressed, use --verbose to show them.
     Error: Exception raised during nimble script execution

The produced SQL as follow:

select p1.author, p1.id
from post as p1
order by p1.authorp1.id desc

The correct SQL should be:

select p1.author, p1.id
from post as p1
order by p1.author, p1.id desc