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

Allow inner subqueries with CTEs in postgres #720

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

tathougies
Copy link
Collaborator

This is a response to #662 which allows postgres (which supports inner CTEs) to embed With monads into regular Q objects, instead of just SqlSelect (which is what selectWith does). The selectWith behavior is correct since that's the standard specified constraint, but pgSelectWith is more flexible.

Docs are included (working on building them again)

@@ -155,13 +155,13 @@ runPgRowReader conn rowIdx res fields (FromBackendRowM readRow) =
Pg.ConversionFailed { Pg.errSQLType = sql
, Pg.errHaskellType = hs
, Pg.errMessage = msg
, Pg.errSQLField = field } ->
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Getting rid of GHC warnings here.

in Q (liftF (QAll (\tblPfx tName ->
let (_, names) = mkFieldNames @Postgres @res (qualifiedField tName)
in fromTable (PgTableSourceSyntax $
mconcat [ emit "(", fromPgSelect (fromSyntax tblPfx), emit ")" ])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Need the ( ) to surround the WITH clause here.


!beam-query
```haskell
!example chinook only:Postgres
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This actually works!

@LaurentRDC
Copy link
Member

Tangential comment: what's the process for generating documentation now?
Most importantly, looks like the documentation is technically also part of tests, so it would be important to add this to the CI pipeline.

@tathougies
Copy link
Collaborator Author

I have a nix expression I use to build documentation. I know ken had some issues with using Nix, but my own workflow is nix heavy. I could try doing it with Docker and seeing if I get it to work. It unfortunately needs a postgresql server as well.

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

Successfully merging this pull request may close these issues.

2 participants