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

Render literals & break up giant renderRead function to allow reuse of e.g. renderExpr across renderings #317

Merged
merged 9 commits into from
Nov 28, 2020

Conversation

robmwalsh
Copy link
Contributor

@robmwalsh robmwalsh commented Nov 22, 2020

not a complete solution but at least fixes string rendering and should make rendering other types easier (at least shows the pattern)

partial solution to #311

also made the rendering functions a bit more user friendly and modular

@robmwalsh robmwalsh changed the title Render literals Render literals & break up giant renderRead function to allow reuse of e.g. renderExpr across renderings Nov 23, 2020
@jczuchnowski
Copy link
Member

jczuchnowski commented Nov 26, 2020

@robmwalsh this is so much needed 🙏 . Could you resolve the conflicts? Unfortunately there were couple of PRs that also modified the rendering and also split the function for reuse.

…iterals

� Conflicts:
�	core/jvm/src/main/scala/zio/sql/expr.scala
�	postgres/src/main/scala/zio/sql/postgresql/PostgresModule.scala
�	postgres/src/test/scala/zio/sql/postgresql/FunctionDefSpec.scala
@robmwalsh
Copy link
Contributor Author

really wish I did this one before the hackathon! It was interesting to see all the hacks people added to get their tests working... I broke a couple of tests which are now @@ ignored but I think they need custom rendering, so can fix once #309 is merged.

btw I've noticed that fmt frequently doesn't do everything it needs to in one pass, so now it runs twice :) the 2nd run is < 1 second if it has nothing to do. I think that's a small price to pay for not having to do another commit/push/spin up CI.

@jczuchnowski
Copy link
Member

No, it's not fmt, it's me :). Sometimes when I resolve conflicts when merging master to someone else's branch, I make mistakes and then the check fails. But I merge anyway, because it would take forever to contact eveyone.
It's just temporary for the hackathon tickets.
Unless it's something else you have in mind.

)

private def postgresStringEscape(s: String): String = s""" '${s}' """
} @@ ignore //todo fix - select(PgClientEncoding())?
Copy link
Member

Choose a reason for hiding this comment

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

from smth is required now. We need to rethink Read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I raised this #323 for this one. I think we should rename Read.Select to Read.SelectFrom and SelectBuilder to Read.Select, both extending a common trait which the renderer can match on.

I think the underlying issue with this one I think is just that it needs parens and other Function0s don't.

This is one of the changes I was talking about in my comment on #290 (comment)

@robmwalsh
Copy link
Contributor Author

This is a bit different, I merged master, ran fmt, refeshed IJ to make sure it picked up the changes, committed, and my branch failed the check.

This stems from the fact that scalafmt isn't entirely idempotent. There are a few issues floating about but they keep closing them because it's a problem with one of their dependencies (e.g. scalameta/scalafmt#917).

Can we please merge this now? The ones that I broke will be resolved with the changes I requested here: #290 (comment)

@jczuchnowski jczuchnowski merged commit ecb9af3 into zio:master Nov 28, 2020
amrkamel pushed a commit to amrkamel/zio-sql that referenced this pull request May 26, 2022
Render literals & break up giant `renderRead` function to allow reuse of e.g. `renderExpr` across renderings
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.

2 participants