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

Pretty Print SQL Queries #1646

Merged
merged 1 commit into from Oct 10, 2019
Merged

Pretty Print SQL Queries #1646

merged 1 commit into from Oct 10, 2019

Conversation

@deusaquilus
Copy link
Collaborator

deusaquilus commented Sep 26, 2019

Pretty printing via:

  • translateContext(query/action/batchAction, true/false)
  • Query log -Dquill.macro.log.pretty=true (default is false)
  • MirrorContext's string(true/false) (TBD)

Using SQL Formatter by vertical-blank.
https://github.com/vertical-blank/sql-formatter

Example output if quill.macro.log.pretty is enabled.

[info] /home/me/work/quill/quill-sql/src/main/scala/io/getquill/MySqlTest.scala:36:16: 
[info]   | SELECT
[info]   |   x2.myEmbname
[info]   | FROM
[info]   |   (
[info]   |     SELECT
[info]   |       DISTINCT x1.name AS myEmbname
[info]   |     FROM
[info]   |       MyParent x1
[info]   |     WHERE
[info]   |       x1.name = 'firstTest'
[info]   |   ) AS x2
[info]   | WHERE
[info]   |   x2.myEmbname = 'test'
[info] 
[info]     println(run(q).string)
  • Unit test all changes
  • Update README.md if applicable
  • Add [WIP] to the pull request title if it's work in progress
  • Squash commits that aren't meaningful changes
  • Run sbt scalariformFormat test:scalariformFormat to make sure that the source files are formatted

@getquill/maintainers

@deusaquilus deusaquilus force-pushed the deusaquilus2:pretty-print branch 2 times, most recently from 932c8cb to b0ce004 Sep 26, 2019
@vertical-blank

This comment has been minimized.

Copy link
Contributor

vertical-blank commented Oct 3, 2019

@deusaquilus
Hi.
For Problem on Scala.js, I'm now working on this.
https://github.com/vertical-blank/scala-sql-formatter

@deusaquilus

This comment has been minimized.

Copy link
Collaborator Author

deusaquilus commented Oct 3, 2019

@vertical-blank Thanks!!! Let me know when you're done and I'll use scala-sql-formatter!
(I'll hold off on doing any more work with this PR until then)

@vertical-blank

This comment has been minimized.

Copy link
Contributor

vertical-blank commented Oct 7, 2019

@deusaquilus
I've just released https://github.com/vertical-blank/scala-sql-formatter.
For usage, please see the readme.md.
I hope this resolves the problem.

@deusaquilus deusaquilus force-pushed the deusaquilus2:pretty-print branch from 7dd5503 to 3c97b8d Oct 10, 2019
@deusaquilus deusaquilus merged commit 64d94f3 into getquill:master Oct 10, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@deusaquilus deusaquilus changed the title [WIP] Pretty Print SQL Queries Pretty Print SQL Queries Nov 28, 2019
@juliano juliano mentioned this pull request Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.