Add WITH RECURSIVE support.
This commit is contained in:
parent
02123005c1
commit
47545ce571
5 changed files with 289 additions and 5 deletions
|
|
@ -1,9 +1,10 @@
|
|||
package jet
|
||||
|
||||
// WITH function creates new with statement from list of common table expressions for specified dialect
|
||||
func WITH(dialect Dialect, cte ...CommonTableExpressionDefinition) func(statement Statement) Statement {
|
||||
func WITH(dialect Dialect, recursive bool, cte ...CommonTableExpressionDefinition) func(statement Statement) Statement {
|
||||
newWithImpl := &withImpl{
|
||||
ctes: cte,
|
||||
recursive: recursive,
|
||||
ctes: cte,
|
||||
serializerStatementInterfaceImpl: serializerStatementInterfaceImpl{
|
||||
dialect: dialect,
|
||||
statementType: WithStatementType,
|
||||
|
|
@ -23,6 +24,7 @@ func WITH(dialect Dialect, cte ...CommonTableExpressionDefinition) func(statemen
|
|||
|
||||
type withImpl struct {
|
||||
serializerStatementInterfaceImpl
|
||||
recursive bool
|
||||
ctes []CommonTableExpressionDefinition
|
||||
primaryStatement SerializerStatement
|
||||
}
|
||||
|
|
@ -31,6 +33,10 @@ func (w withImpl) serialize(statement StatementType, out *SQLBuilder, options ..
|
|||
out.NewLine()
|
||||
out.WriteString("WITH")
|
||||
|
||||
if w.recursive {
|
||||
out.WriteString("RECURSIVE")
|
||||
}
|
||||
|
||||
for i, cte := range w.ctes {
|
||||
if i > 0 {
|
||||
out.WriteString(",")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue