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

Fix non-exhaustive patterns in 'unsafeSqlAggregateFunction' #238

Merged
merged 4 commits into from
Feb 21, 2021

Conversation

arthurxavierx
Copy link
Contributor

@arthurxavierx arthurxavierx commented Feb 5, 2021

Got the following error when using unsafeSqlAggregateFunction:

An exception has occurred: src/Database/Esqueleto/PostgreSQL.hs:94:30-50: Non-exhaustive patterns in lambda

This PR fixes the problem.


Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR.
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts).

-- Since: 3.4.0.2
valueToRawSqlParens :: SqlExpr (Value a) -> IdentInfo -> (TLB.Builder, [PersistValue])
valueToRawSqlParens (ERaw p f) = (first (parensM p)) . f
valueToRawSqlParens (ECompositeKey _) = throw (CompositeKeyErr SqlCaseError)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed that the error type thrown here is different. Any suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems risky to have this same function repeated and specialized more than once in the codebase. I'll go with making the error an argument here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like how error handling is done in esqueleto at the moment. Since this is a moving of code, it's probably fine to leave as-is. Ideally we'd just fix the representation so this can't happen, but it's not clear to me the best way to do that 🤔

@@ -91,7 +91,7 @@ unsafeSqlAggregateFunction name mode args orderByClauses = ERaw Never $ \info ->
[] -> ""
(_:_) -> " "
(argsTLB, argsVals) =
uncommas' $ map (\(ERaw _ f) -> f info) $ toArgList args
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, we even have the right warning on. I need to do a warnings-clean PR on the project soon.

@belevy
Copy link
Collaborator

belevy commented Feb 5, 2021

This actually shouldn't be a problem in my work to unify the representation of SqlExpr

@arthurxavierx
Copy link
Contributor Author

I think this is good to merge, but CI isn't helping me :p

@belevy belevy merged commit a61f552 into bitemyapp:master Feb 21, 2021
@belevy
Copy link
Collaborator

belevy commented Feb 21, 2021

@parsonsmatt This is fine. We should push 3.4.1.0 to hackage.

@belevy
Copy link
Collaborator

belevy commented Feb 21, 2021

looks like this changed the order of JSON objects in the postgresql test suite. @arthurxavierx @parsonsmatt i dont particularly care to fix this as i think 3.5.0 essentially reverts this change.

@arthurxavierx
Copy link
Contributor Author

Thank you @belevy! :)

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

Successfully merging this pull request may close these issues.

3 participants