[MySQL] Add support for WITH statements and Common Table Expressions.
This commit is contained in:
parent
8aa894730c
commit
f5fae577d7
6 changed files with 42 additions and 13 deletions
26
mysql/with_statement.go
Normal file
26
mysql/with_statement.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package mysql
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
// CommonTableExpression contains information about a CTE.
|
||||
type CommonTableExpression struct {
|
||||
readableTableInterfaceImpl
|
||||
jet.CommonTableExpression
|
||||
}
|
||||
|
||||
// WITH function creates new WITH statement from list of common table expressions
|
||||
func WITH(cte ...jet.CommonTableExpressionDefinition) func(statement jet.SerializerStatement) Statement {
|
||||
return jet.WITH(Dialect, cte...)
|
||||
}
|
||||
|
||||
// CTE creates new named CommonTableExpression
|
||||
func CTE(name string) CommonTableExpression {
|
||||
cte := CommonTableExpression{
|
||||
readableTableInterfaceImpl: readableTableInterfaceImpl{},
|
||||
CommonTableExpression: jet.CTE(name),
|
||||
}
|
||||
|
||||
cte.parent = &cte
|
||||
|
||||
return cte
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue