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

mixing up order of orderBy clause passes typechecking, produces bad sql #142

Open
mwotton opened this issue Jul 11, 2016 · 0 comments
Open

Comments

@mwotton
Copy link

mwotton commented Jul 11, 2016

      select $ from $ \(jobs,jobUpdates) ->
      distinctOn [ don (jobUpdates ^. JobUpdateJobId) ] $ do
        orderBy [ desc (jobUpdates ^. JobUpdateAt)
                , desc (jobUpdates ^. JobUpdateJobId) ]
        where_ (jobs ^. JobCompanyId ==. val companyk)
        where_ (jobUpdates ^. JobUpdateJobId ==. jobs ^. JobId)
        return jobUpdates

with the error message

       uncaught exception: SqlError (SqlError {sqlState = "42P10", sqlExecStatus = FatalError, sqlErrorMsg = "SELECT DISTINCT ON expressions must match initial ORDER BY expressions", sqlErrorDetail = "", sqlErrorHint = ""})

I understand why this is happening, but it'd be really nice if typechecked code producing invalid SQL was less of a regular occurrence in my workflow.

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

No branches or pull requests

1 participant