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

run-time error "column t0.res0 does not exist" #701

Open
jerbaroo opened this issue Mar 26, 2024 · 1 comment
Open

run-time error "column t0.res0 does not exist" #701

jerbaroo opened this issue Mar 26, 2024 · 1 comment
Labels

Comments

@jerbaroo
Copy link

For a table that looks something like:

filename version foo

I am looking to write a query that returns, for each given filename, the row with greatest version for that filename.

Considering first the simple case of a query for a single filename, we can write:

selectLatest fname =
  runSelectReturningOne
    $ limit_ 1
    $ orderBy_ (desc_ . (.version))
    $ filter_ (Schema.File.name >>> (==. val_ fname))
    $ all_ db.fileTable

I am trying to adjust this to support multiple filenames:

selectLatest fnames =
  runSelectReturningList do
    -- for each filename in the given list..
    fname <- values_ $ val_ <$> fnames
    -- ..find the row with maximum version matching the filename.
    limit_ 1
      $ orderBy_ (desc_ . (.version))
      $ filter_ (Schema.File.name >>> (==. val_ fname))
      $ all_ db.fileTable

However this results in a run-time error:

SqlError {sqlState = "42703", sqlExecStatus = FatalError, sqlErrorMsg = "column t0.res0 does not exist", sqlErrorDetail = "", sqlErrorHint = "There is a column named \"res0\" in table \"t0\", but it cannot be referenced from this part of the query."}
@kmicklas kmicklas added the bug label Jun 8, 2024
@LaurentRDC
Copy link
Member

LaurentRDC commented Jul 4, 2024

Would it be possible to provide more information about this issue? Ideally a minimal reproducible example?

I tried to jerry-rig this into a small reproducible example but couldn't make it type-check

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

No branches or pull requests

3 participants