-
Notifications
You must be signed in to change notification settings - Fork 348
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
Returning Record #1489
Returning Record #1489
Conversation
838eb41
to
7219984
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the middle of PR I've lost on various changes, it really makes sense to me to split this PR (more in a comment below).
Also I've notice that in a lot of places returning
itself is changed to returningGenerated
, but the first one is not deleted from codebase, so it means that both will be in use? A short summary of a returning design in PR as well as in readme would be nice
@@ -175,6 +181,9 @@ trait CqlIdiom extends Idiom { | |||
case _: Returning => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: _: ReturningGenerated | _: Returning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call!
@@ -69,6 +69,10 @@ case class Function(params: List[Ident], body: Ast) extends Ast | |||
|
|||
case class Ident(name: String) extends Ast | |||
|
|||
// Like identity but is but defined in a clause external to the query. Currently this is used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suffering from "The Curse of Knowledge" here. What part do you mean?
@@ -0,0 +1,139 @@ | |||
package io.getquill.dsl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make a separate commit for such refactor before introducing returning record feature. So it'd be easy to track
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense. I'll try to separate it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. There are 4 commits now.
case ret: io.getquill.ast.ReturningAction => | ||
io.getquill.norm.ExpandReturning.applyMap(ret)( | ||
(ast, statement) => io.getquill.context.Expand(${c.prefix}, ast, statement, idiom, naming).string | ||
)(idiom, naming) | ||
case ast => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing case io.getquill.ast.Returning
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So ReturningAction is a de-composer that matches Returning or ReturningGenerated, I defined it in Ast.scala
. I decide to write it since their structure is identical. I'm not sure I like the name "ReturningAction" though. Maybe "ReturningAst"? Or maybe it shouldn't start with a capital letter. Any thoughts?
Im sorry that I forgot to mention something important. The |
7d31c72
to
f58be32
Compare
da165c8
to
341016f
Compare
The other thing that we realized was that whether a single column (MySQL, Sqlite etc...), multiple columns (Oracle) or multiple columns with an actual RETURNING clause that supports sql operations (Postgres) is supported has to be controlled by the idiom as opposed to the context. MirrorContext for instance has to generate RETURNING clauses for only Postgres but... allow multiple column tuples/case-classes for Oracle and allow only one return variable for other databases the same way in MirrorContext as well as JdbcContext. So the dialect has to control these things. Also, |
341016f
to
f1c8eb4
Compare
@deusaquilus Okay, now it's clear, great work! Except missing readme update, everything else lgtm. |
Trying out build similar to #1383 (fix for #572).
README.md
if applicable[WIP]
to the pull request title if it's work in progresssbt scalariformFormat test:scalariformFormat
to make sure that the source files are formatted@getquill/maintainers