Merge remote-tracking branch 'upstream/master' into stmt-cache2
# Conflicts: # tests/postgres/alltypes_test.go # tests/postgres/northwind_test.go # tests/postgres/sample_test.go # tests/postgres/update_test.go # tests/sqlite/insert_test.go # tests/sqlite/main_test.go # tests/sqlite/sample_test.go # tests/sqlite/update_test.go
This commit is contained in:
commit
4bb9775134
97 changed files with 2306 additions and 537 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package sqlite
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/go-jet/jet/v2/internal/jet"
|
||||
)
|
||||
|
||||
|
|
@ -23,6 +24,9 @@ func newDialect() jet.Dialect {
|
|||
return "?"
|
||||
},
|
||||
ReservedWords: reservedWords2,
|
||||
ValuesDefaultColumnName: func(index int) string {
|
||||
return fmt.Sprintf("column%d", index+1)
|
||||
},
|
||||
}
|
||||
|
||||
return jet.NewDialect(mySQLDialectParams)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ type DateTimeExpression = jet.TimestampExpression
|
|||
// TimestampExpression interface
|
||||
type TimestampExpression = jet.TimestampExpression
|
||||
|
||||
// RowExpression interface
|
||||
type RowExpression = jet.RowExpression
|
||||
|
||||
// BoolExp is bool expression wrapper around arbitrary expression.
|
||||
// Allows go compiler to see any expression as bool expression.
|
||||
// Does not add sql cast to generated sql builder output.
|
||||
|
|
@ -73,6 +76,11 @@ var DateTimeExp = jet.TimestampExp
|
|||
// Does not add sql cast to generated sql builder output.
|
||||
var TimestampExp = jet.TimestampExp
|
||||
|
||||
// RowExp serves as a wrapper for an arbitrary expression, treating it as a row expression.
|
||||
// This enables the Go compiler to interpret any expression as a row expression
|
||||
// Note: This does not modify the generated SQL builder output by adding a SQL CAST operation.
|
||||
var RowExp = jet.RowExp
|
||||
|
||||
// CustomExpression is used to define custom expressions.
|
||||
var CustomExpression = jet.CustomExpression
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ var (
|
|||
OR = jet.OR
|
||||
)
|
||||
|
||||
// ROW is construct one table row from list of expressions.
|
||||
func ROW(expressions ...Expression) Expression {
|
||||
return jet.NewFunc("", expressions, nil)
|
||||
// ROW function is used to create a tuple value that consists of a set of expressions or column values.
|
||||
func ROW(expressions ...Expression) RowExpression {
|
||||
return jet.WRAP(Dialect, expressions...)
|
||||
}
|
||||
|
||||
// ------------------ Mathematical functions ---------------//
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ func (s *selectStatementImpl) LOCK_IN_SHARE_MODE() SelectStatement {
|
|||
}
|
||||
|
||||
func (s *selectStatementImpl) AsTable(alias string) SelectTable {
|
||||
return newSelectTable(s, alias)
|
||||
return newSelectTable(s, alias, nil)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ type selectTableImpl struct {
|
|||
readableTableInterfaceImpl
|
||||
}
|
||||
|
||||
func newSelectTable(selectStmt jet.SerializerHasProjections, alias string) SelectTable {
|
||||
func newSelectTable(selectStmt jet.SerializerHasProjections, alias string, columnAliases []jet.ColumnExpression) SelectTable {
|
||||
subQuery := &selectTableImpl{
|
||||
SelectTable: jet.NewSelectTable(selectStmt, alias),
|
||||
SelectTable: jet.NewSelectTable(selectStmt, alias, columnAliases),
|
||||
}
|
||||
|
||||
subQuery.readableTableInterfaceImpl.parent = subQuery
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ func (s *setStatementImpl) OFFSET(offset int64) setStatement {
|
|||
}
|
||||
|
||||
func (s *setStatementImpl) AsTable(alias string) SelectTable {
|
||||
return newSelectTable(s, alias)
|
||||
return newSelectTable(s, alias, nil)
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
|
|||
26
sqlite/values.go
Normal file
26
sqlite/values.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package sqlite
|
||||
|
||||
import "github.com/go-jet/jet/v2/internal/jet"
|
||||
|
||||
type values struct {
|
||||
jet.Values
|
||||
}
|
||||
|
||||
// VALUES is a table value constructor that computes a set of one or more rows as a temporary constant table.
|
||||
// Each row is defined by the ROW constructor, which takes one or more expressions.
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// VALUES(
|
||||
// ROW(Int32(204), Float32(1.21)),
|
||||
// ROW(Int32(207), Float32(1.02)),
|
||||
// )
|
||||
func VALUES(rows ...RowExpression) values {
|
||||
return values{Values: jet.Values(rows)}
|
||||
}
|
||||
|
||||
// AS assigns an alias to the temporary VALUES table, allowing it to be referenced
|
||||
// within SQL FROM clauses, just like a regular table.
|
||||
func (v values) AS(alias string) SelectTable {
|
||||
return newSelectTable(v, alias, nil)
|
||||
}
|
||||
|
|
@ -6,8 +6,8 @@ import "github.com/go-jet/jet/v2/internal/jet"
|
|||
type CommonTableExpression interface {
|
||||
SelectTable
|
||||
|
||||
AS(statement jet.SerializerStatement) CommonTableExpression
|
||||
AS_NOT_MATERIALIZED(statement jet.SerializerStatement) CommonTableExpression
|
||||
AS(statement jet.SerializerHasProjections) CommonTableExpression
|
||||
AS_NOT_MATERIALIZED(statement jet.SerializerHasProjections) CommonTableExpression
|
||||
// ALIAS is used to create another alias of the CTE, if a CTE needs to appear multiple times in the main query.
|
||||
ALIAS(alias string) SelectTable
|
||||
|
||||
|
|
@ -42,13 +42,13 @@ func CTE(name string, columns ...jet.ColumnExpression) CommonTableExpression {
|
|||
}
|
||||
|
||||
// AS is used to define a CTE query
|
||||
func (c *commonTableExpression) AS(statement jet.SerializerStatement) CommonTableExpression {
|
||||
func (c *commonTableExpression) AS(statement jet.SerializerHasProjections) CommonTableExpression {
|
||||
c.CommonTableExpression.Statement = statement
|
||||
return c
|
||||
}
|
||||
|
||||
// AS_NOT_MATERIALIZED is used to define not materialized CTE query
|
||||
func (c *commonTableExpression) AS_NOT_MATERIALIZED(statement jet.SerializerStatement) CommonTableExpression {
|
||||
func (c *commonTableExpression) AS_NOT_MATERIALIZED(statement jet.SerializerHasProjections) CommonTableExpression {
|
||||
c.CommonTableExpression.NotMaterialized = true
|
||||
c.CommonTableExpression.Statement = statement
|
||||
return c
|
||||
|
|
@ -60,7 +60,7 @@ func (c *commonTableExpression) internalCTE() *jet.CommonTableExpression {
|
|||
|
||||
// ALIAS is used to create another alias of the CTE, if a CTE needs to appear multiple times in the main query.
|
||||
func (c *commonTableExpression) ALIAS(name string) SelectTable {
|
||||
return newSelectTable(c, name)
|
||||
return newSelectTable(c, name, nil)
|
||||
}
|
||||
|
||||
func toInternalCTE(ctes []CommonTableExpression) []*jet.CommonTableExpression {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue