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

Add sqlWhereAnyE #16

Merged
merged 2 commits into from Nov 19, 2018
Merged

Add sqlWhereAnyE #16

merged 2 commits into from Nov 19, 2018

Conversation

thoferon
Copy link
Contributor

No description provided.

Copy link
Contributor

@23Skidoo 23Skidoo left a comment

Choose a reason for hiding this comment

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

LGTM modulo comments.

let sql = sqlForWhereAny l
sqlWhereE (DBBaseLineConditionIsFalse sql) sql

sqlWhereAnyE :: (DBExtraException e, MonadState v m, SqlWhere v) => e -> [State SqlAll ()] -> m ()
Copy link
Contributor

@23Skidoo 23Skidoo Nov 19, 2018

Choose a reason for hiding this comment

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

I'm aware that most top-level functions in this file lack Haddock comments, but would be nice if we started adding them to the new ones at least.

sqlWhereAny l = sqlWhere $ "(" <+> smintercalate "OR" (map (parenthesize . toSQLCommand . flip execState (SqlAll [])) l) <+> ")"
sqlWhereAny l = do
let sql = sqlForWhereAny l
sqlWhereE (DBBaseLineConditionIsFalse sql) sql
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you just sqlWhere here instead of inlining it?

sqlWhereAnyE :: (DBExtraException e, MonadState v m, SqlWhere v) => e -> [State SqlAll ()] -> m ()
sqlWhereAnyE e = sqlWhereE e . sqlForWhereAny

sqlForWhereAny :: [State SqlAll ()] -> SQL
Copy link
Contributor

Choose a reason for hiding this comment

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

sqlFor naming convention is not used anywhere else in this file, IMO something like sqlWhereAnyImpl would be more self-explanatory.

sqlWhereAnyE :: (DBExtraException e, MonadState v m, SqlWhere v) => e -> [State SqlAll ()] -> m ()
sqlWhereAnyE e = sqlWhereE e . sqlForWhereAny

sqlForWhereAny :: [State SqlAll ()] -> SQL
Copy link
Contributor

Choose a reason for hiding this comment

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

[State SqlAll ()]

From looking at the code, it seems that it would make sense to add a SqlAny newtype as well, though that's a bigger refactoring (and therefore not required for this PR to be merged).

@23Skidoo
Copy link
Contributor

Travis failure is due to the released hpqtypes not supporting GHC 8.6 yet.

@23Skidoo
Copy link
Contributor

Made a Hackage revision for hpqtypes-1.6.0.0, this should made the build green.

@23Skidoo
Copy link
Contributor

It's green, merging. Will do a minor release later today.

@23Skidoo 23Skidoo merged commit 75c20a6 into master Nov 19, 2018
@23Skidoo 23Skidoo deleted the dev-thoferon-sqlwhereanye branch November 19, 2018 11:59
@23Skidoo
Copy link
Contributor

Released hpqtypes-extras-1.6.3.0 on Hackage.

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.

None yet

2 participants