Package structure refactor.
This commit is contained in:
parent
3d8e872336
commit
23fd973699
125 changed files with 2401 additions and 1818 deletions
|
|
@ -1,48 +1,47 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var dateVar = Date(2000, 12, 30)
|
||||
|
||||
func TestDateExpressionEQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.EQ(table2ColDate), "(table1.col_date = table2.col_date)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.EQ(dateVar), "(table1.col_date = $1::DATE)", "2000-12-30")
|
||||
assertClauseSerialize(t, table1ColDate.EQ(table2ColDate), "(table1.col_date = table2.col_date)")
|
||||
assertClauseSerialize(t, table1ColDate.EQ(dateVar), "(table1.col_date = $1::DATE)", "2000-12-30")
|
||||
}
|
||||
|
||||
func TestDateExpressionNOT_EQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.NOT_EQ(table2ColDate), "(table1.col_date != table2.col_date)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.NOT_EQ(dateVar), "(table1.col_date != $1::DATE)", "2000-12-30")
|
||||
assertClauseSerialize(t, table1ColDate.NOT_EQ(table2ColDate), "(table1.col_date != table2.col_date)")
|
||||
assertClauseSerialize(t, table1ColDate.NOT_EQ(dateVar), "(table1.col_date != $1::DATE)", "2000-12-30")
|
||||
}
|
||||
|
||||
func TestDateExpressionIS_DISTINCT_FROM(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.IS_DISTINCT_FROM(table2ColDate), "(table1.col_date IS DISTINCT FROM table2.col_date)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.IS_DISTINCT_FROM(dateVar), "(table1.col_date IS DISTINCT FROM $1::DATE)", "2000-12-30")
|
||||
assertClauseSerialize(t, table1ColDate.IS_DISTINCT_FROM(table2ColDate), "(table1.col_date IS DISTINCT FROM table2.col_date)")
|
||||
assertClauseSerialize(t, table1ColDate.IS_DISTINCT_FROM(dateVar), "(table1.col_date IS DISTINCT FROM $1::DATE)", "2000-12-30")
|
||||
}
|
||||
|
||||
func TestDateExpressionIS_NOT_DISTINCT_FROM(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.IS_NOT_DISTINCT_FROM(table2ColDate), "(table1.col_date IS NOT DISTINCT FROM table2.col_date)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.IS_NOT_DISTINCT_FROM(dateVar), "(table1.col_date IS NOT DISTINCT FROM $1::DATE)", "2000-12-30")
|
||||
assertClauseSerialize(t, table1ColDate.IS_NOT_DISTINCT_FROM(table2ColDate), "(table1.col_date IS NOT DISTINCT FROM table2.col_date)")
|
||||
assertClauseSerialize(t, table1ColDate.IS_NOT_DISTINCT_FROM(dateVar), "(table1.col_date IS NOT DISTINCT FROM $1::DATE)", "2000-12-30")
|
||||
}
|
||||
|
||||
func TestDateExpressionGT(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.GT(table2ColDate), "(table1.col_date > table2.col_date)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.GT(dateVar), "(table1.col_date > $1::DATE)", "2000-12-30")
|
||||
assertClauseSerialize(t, table1ColDate.GT(table2ColDate), "(table1.col_date > table2.col_date)")
|
||||
assertClauseSerialize(t, table1ColDate.GT(dateVar), "(table1.col_date > $1::DATE)", "2000-12-30")
|
||||
}
|
||||
|
||||
func TestDateExpressionGT_EQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.GT_EQ(table2ColDate), "(table1.col_date >= table2.col_date)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.GT_EQ(dateVar), "(table1.col_date >= $1::DATE)", "2000-12-30")
|
||||
assertClauseSerialize(t, table1ColDate.GT_EQ(table2ColDate), "(table1.col_date >= table2.col_date)")
|
||||
assertClauseSerialize(t, table1ColDate.GT_EQ(dateVar), "(table1.col_date >= $1::DATE)", "2000-12-30")
|
||||
}
|
||||
|
||||
func TestDateExpressionLT(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.LT(table2ColDate), "(table1.col_date < table2.col_date)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.LT(dateVar), "(table1.col_date < $1::DATE)", "2000-12-30")
|
||||
assertClauseSerialize(t, table1ColDate.LT(table2ColDate), "(table1.col_date < table2.col_date)")
|
||||
assertClauseSerialize(t, table1ColDate.LT(dateVar), "(table1.col_date < $1::DATE)", "2000-12-30")
|
||||
}
|
||||
|
||||
func TestDateExpressionLT_EQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.LT_EQ(table2ColDate), "(table1.col_date <= table2.col_date)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColDate.LT_EQ(dateVar), "(table1.col_date <= $1::DATE)", "2000-12-30")
|
||||
assertClauseSerialize(t, table1ColDate.LT_EQ(table2ColDate), "(table1.col_date <= table2.col_date)")
|
||||
assertClauseSerialize(t, table1ColDate.LT_EQ(dateVar), "(table1.col_date <= $1::DATE)", "2000-12-30")
|
||||
}
|
||||
|
|
|
|||
70
postgres/dialect.go
Normal file
70
postgres/dialect.go
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/internal/jet"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var Dialect = NewDialect()
|
||||
|
||||
func NewDialect() jet.Dialect {
|
||||
|
||||
dialectParams := jet.DialectParams{
|
||||
Name: "PostgreSQL",
|
||||
PackageName: "postgres",
|
||||
CastOverride: castFunc,
|
||||
AliasQuoteChar: '"',
|
||||
IdentifierQuoteChar: '"',
|
||||
ArgumentPlaceholder: func(ord int) string {
|
||||
return "$" + strconv.Itoa(ord)
|
||||
},
|
||||
UpdateAssigment: postgresUpdateAssigment,
|
||||
SupportsReturning: true,
|
||||
}
|
||||
|
||||
return jet.NewDialect(dialectParams)
|
||||
}
|
||||
|
||||
func castFunc(expression jet.Expression, castType string) jet.SerializeFunc {
|
||||
return func(statement jet.StatementType, out *jet.SqlBuilder, options ...jet.SerializeOption) error {
|
||||
if err := jet.Serialize(expression, statement, out, options...); err != nil {
|
||||
return err
|
||||
}
|
||||
out.WriteString("::" + castType)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func postgresUpdateAssigment(columns []jet.IColumn, values []jet.Clause, out *jet.SqlBuilder) (err error) {
|
||||
if len(columns) > 1 {
|
||||
out.WriteString("(")
|
||||
}
|
||||
|
||||
err = jet.SerializeColumnNames(columns, out)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if len(columns) > 1 {
|
||||
out.WriteString(")")
|
||||
}
|
||||
|
||||
out.WriteString("=")
|
||||
|
||||
if len(values) > 1 {
|
||||
out.WriteString("(")
|
||||
}
|
||||
|
||||
err = jet.SerializeClauseList(jet.UpdateStatementType, values, out)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if len(values) > 1 {
|
||||
out.WriteString(")")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
5
postgres/expressions.go
Normal file
5
postgres/expressions.go
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
type Expression jet.Expression
|
||||
|
|
@ -2,7 +2,7 @@ package postgres
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/go-jet/jet"
|
||||
"github.com/go-jet/jet/internal/jet"
|
||||
)
|
||||
|
||||
type cast interface {
|
||||
|
|
@ -37,7 +37,7 @@ type castImpl struct {
|
|||
jet.CastImpl
|
||||
}
|
||||
|
||||
func CAST(expr jet.Expression) cast {
|
||||
func CAST(expr Expression) cast {
|
||||
castImpl := &castImpl{}
|
||||
|
||||
castImpl.CastImpl = jet.NewCastImpl(expr)
|
||||
|
|
|
|||
|
|
@ -1,65 +1,64 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExpressionCAST_AS(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(String("test")).AS("text"), `$1::text`, "test")
|
||||
assertClauseSerialize(t, CAST(String("test")).AS("text"), `$1::text`, "test")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_BOOL(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(Int(1)).AS_BOOL(), "$1::boolean", int64(1))
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_BOOL(), "table2.col3::boolean")
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3.ADD(table2Col3)).AS_BOOL(), "(table2.col3 + table2.col3)::boolean")
|
||||
assertClauseSerialize(t, CAST(Int(1)).AS_BOOL(), "$1::boolean", int64(1))
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_BOOL(), "table2.col3::boolean")
|
||||
assertClauseSerialize(t, CAST(table2Col3.ADD(table2Col3)).AS_BOOL(), "(table2.col3 + table2.col3)::boolean")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_SMALLINT(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_SMALLINT(), "table2.col3::smallint")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_SMALLINT(), "table2.col3::smallint")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_INTEGER(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_INTEGER(), "table2.col3::integer")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_INTEGER(), "table2.col3::integer")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_BIGINT(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_BIGINT(), "table2.col3::bigint")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_BIGINT(), "table2.col3::bigint")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_NUMERIC(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_NUMERIC(11, 11), "table2.col3::numeric(11, 11)")
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_NUMERIC(11), "table2.col3::numeric(11)")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_NUMERIC(11, 11), "table2.col3::numeric(11, 11)")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_NUMERIC(11), "table2.col3::numeric(11)")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_REAL(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_REAL(), "table2.col3::real")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_REAL(), "table2.col3::real")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_DOUBLE(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_DOUBLE(), "table2.col3::double precision")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_DOUBLE(), "table2.col3::double precision")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_TEXT(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_TEXT(), "table2.col3::text")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_TEXT(), "table2.col3::text")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_DATE(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_DATE(), "table2.col3::DATE")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_DATE(), "table2.col3::DATE")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_TIME(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_TIME(), "table2.col3::time without time zone")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_TIME(), "table2.col3::time without time zone")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_TIMEZ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_TIMEZ(), "table2.col3::time with time zone")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_TIMEZ(), "table2.col3::time with time zone")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_TIMESTAMP(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_TIMESTAMP(), "table2.col3::timestamp without time zone")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_TIMESTAMP(), "table2.col3::timestamp without time zone")
|
||||
}
|
||||
|
||||
func TestExpressionCAST_AS_TIMESTAMPZ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, CAST(table2Col3).AS_TIMESTAMPZ(), "table2.col3::timestamp with time zone")
|
||||
assertClauseSerialize(t, CAST(table2Col3).AS_TIMESTAMPZ(), "table2.col3::timestamp with time zone")
|
||||
}
|
||||
|
|
|
|||
9
postgres/postgres_column.go
Normal file
9
postgres/postgres_column.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
type Column jet.Column
|
||||
|
||||
type IColumnList jet.IColumnList
|
||||
|
||||
var ColumnList = jet.ColumnList
|
||||
5
postgres/postgres_enum.go
Normal file
5
postgres/postgres_enum.go
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
var NewEnumValue = jet.NewEnumValue
|
||||
5
postgres/postgres_expressions.go
Normal file
5
postgres/postgres_expressions.go
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
var RAW = jet.RAW
|
||||
93
postgres/postgres_functions.go
Normal file
93
postgres/postgres_functions.go
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
var ROW = jet.ROW
|
||||
|
||||
// ------------------ Mathematical functions ---------------//
|
||||
|
||||
var ABSf = jet.ABSf
|
||||
var ABSi = jet.ABSi
|
||||
var POW = jet.POW
|
||||
var POWER = jet.POWER
|
||||
var SQRT = jet.SQRT
|
||||
var CBRT = jet.CBRT
|
||||
var CEIL = jet.CEIL
|
||||
var FLOOR = jet.FLOOR
|
||||
var ROUND = jet.ROUND
|
||||
var SIGN = jet.SIGN
|
||||
var TRUNC = jet.TRUNC
|
||||
var LN = jet.LN
|
||||
var LOG = jet.LOG
|
||||
|
||||
// ----------------- Aggregate functions -------------------//
|
||||
|
||||
var AVG = jet.AVG
|
||||
var BIT_AND = jet.BIT_AND
|
||||
var BIT_OR = jet.BIT_OR
|
||||
var BOOL_AND = jet.BOOL_AND
|
||||
var BOOL_OR = jet.BOOL_OR
|
||||
var COUNT = jet.COUNT
|
||||
var EVERY = jet.EVERY
|
||||
var MAXf = jet.MAXf
|
||||
var MAXi = jet.MAXi
|
||||
var MINf = jet.MINf
|
||||
var MINi = jet.MINi
|
||||
var SUMf = jet.SUMf
|
||||
var SUMi = jet.SUMi
|
||||
|
||||
//--------------------- String functions ------------------//
|
||||
|
||||
var BIT_LENGTH = jet.BIT_LENGTH
|
||||
var CHAR_LENGTH = jet.CHAR_LENGTH
|
||||
var OCTET_LENGTH = jet.OCTET_LENGTH
|
||||
var LOWER = jet.LOWER
|
||||
var UPPER = jet.UPPER
|
||||
var BTRIM = jet.BTRIM
|
||||
var LTRIM = jet.LTRIM
|
||||
var RTRIM = jet.RTRIM
|
||||
var CHR = jet.CHR
|
||||
var CONVERT = jet.CONVERT
|
||||
var CONVERT_FROM = jet.CONVERT_FROM
|
||||
var CONVERT_TO = jet.CONVERT_TO
|
||||
var ENCODE = jet.ENCODE
|
||||
var DECODE = jet.DECODE
|
||||
var INITCAP = jet.INITCAP
|
||||
var LEFT = jet.LEFT
|
||||
var RIGHT = jet.RIGHT
|
||||
var LENGTH = jet.LENGTH
|
||||
var LPAD = jet.LPAD
|
||||
var RPAD = jet.RPAD
|
||||
var MD5 = jet.MD5
|
||||
var REPEAT = jet.REPEAT
|
||||
var REPLACE = jet.REPLACE
|
||||
var REVERSE = jet.REVERSE
|
||||
var STRPOS = jet.STRPOS
|
||||
var SUBSTR = jet.SUBSTR
|
||||
var TO_ASCII = jet.TO_ASCII
|
||||
var TO_HEX = jet.TO_HEX
|
||||
|
||||
//----------Data Type Formatting Functions ----------------------//
|
||||
|
||||
var TO_CHAR = jet.TO_CHAR
|
||||
var TO_DATE = jet.TO_DATE
|
||||
var TO_NUMBER = jet.TO_NUMBER
|
||||
var TO_TIMESTAMP = jet.TO_TIMESTAMP
|
||||
|
||||
//----------------- Date/Time Functions and Operators ------------//
|
||||
|
||||
var CURRENT_DATE = jet.CURRENT_DATE
|
||||
var CURRENT_TIME = jet.CURRENT_TIME
|
||||
var CURRENT_TIMESTAMP = jet.CURRENT_TIMESTAMP
|
||||
var LOCALTIME = jet.LOCALTIME
|
||||
var LOCALTIMESTAMP = jet.LOCALTIMESTAMP
|
||||
var NOW = jet.NOW
|
||||
|
||||
// --------------- Conditional Expressions Functions -------------//
|
||||
|
||||
var COALESCE = jet.COALESCE
|
||||
var NULLIF = jet.NULLIF
|
||||
var GREATEST = jet.GREATEST
|
||||
var LEAST = jet.LEAST
|
||||
var EXISTS = jet.EXISTS
|
||||
var CASE = jet.CASE
|
||||
15
postgres/postgres_keywords.go
Normal file
15
postgres/postgres_keywords.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
const (
|
||||
// DEFAULT is jet equivalent of SQL DEFAULT
|
||||
DEFAULT = jet.DEFAULT
|
||||
)
|
||||
|
||||
var (
|
||||
// NULL is jet equivalent of SQL NULL
|
||||
NULL = jet.NULL
|
||||
// STAR is jet equivalent of SQL *
|
||||
STAR = jet.STAR
|
||||
)
|
||||
27
postgres/postgres_literal.go
Normal file
27
postgres/postgres_literal.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
var Bool = jet.Bool
|
||||
var Int = jet.Int
|
||||
var Float = jet.Float
|
||||
var String = jet.String
|
||||
var Date = func(year, month, day int) DateExpression {
|
||||
return CAST(jet.Date(year, month, day)).AS_DATE()
|
||||
}
|
||||
|
||||
var Time = func(hour, minute, second, milliseconds int) TimeExpression {
|
||||
return CAST(jet.Time(hour, minute, second, milliseconds)).AS_TIME()
|
||||
}
|
||||
|
||||
var Timez = func(hour, minute, second, milliseconds int, timezone int) TimezExpression {
|
||||
return CAST(jet.Timez(hour, minute, second, milliseconds, timezone)).AS_TIMEZ()
|
||||
}
|
||||
|
||||
var Timestamp = func(year, month, day, hour, minute, second, milliseconds int) TimestampExpression {
|
||||
return CAST(jet.Timestamp(year, month, day, hour, minute, second, milliseconds)).AS_TIMESTAMP()
|
||||
}
|
||||
|
||||
var Timestampz = func(year, month, day, hour, minute, second, milliseconds int, timezone int) TimestampzExpression {
|
||||
return CAST(jet.Timestampz(year, month, day, hour, minute, second, milliseconds, timezone)).AS_TIMESTAMPZ()
|
||||
}
|
||||
21
postgres/postgres_lock.go
Normal file
21
postgres/postgres_lock.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
type TableLockMode jet.TableLockMode
|
||||
|
||||
// Lock types for LockStatement.
|
||||
const (
|
||||
LOCK_ACCESS_SHARE = "ACCESS SHARE"
|
||||
LOCK_ROW_SHARE = "ROW SHARE"
|
||||
LOCK_ROW_EXCLUSIVE = "ROW EXCLUSIVE"
|
||||
LOCK_SHARE_UPDATE_EXCLUSIVE = "SHARE UPDATE EXCLUSIVE"
|
||||
LOCK_SHARE = "SHARE"
|
||||
LOCK_SHARE_ROW_EXCLUSIVE = "SHARE ROW EXCLUSIVE"
|
||||
LOCK_EXCLUSIVE = "EXCLUSIVE"
|
||||
LOCK_ACCESS_EXCLUSIVE = "ACCESS EXCLUSIVE"
|
||||
)
|
||||
|
||||
type LockStatement jet.LockStatement
|
||||
|
||||
var LOCK = jet.LOCK
|
||||
13
postgres/postgres_operators.go
Normal file
13
postgres/postgres_operators.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
// --------- Arithmetic operators -------------//
|
||||
|
||||
var MINUSi = jet.MINUSi
|
||||
var MINUSf = jet.MINUSf
|
||||
|
||||
//----------- Logical operators ---------------//
|
||||
|
||||
var NOT = jet.NOT
|
||||
var BIT_NOT = jet.BIT_NOT
|
||||
42
postgres/postgres_select.go
Normal file
42
postgres/postgres_select.go
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
type SelectStatement jet.SelectStatement
|
||||
|
||||
var SELECT = jet.SELECT
|
||||
|
||||
func UNION(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement {
|
||||
return jet.UNION(lhs, rhs, toJetSelects(selects...)...)
|
||||
}
|
||||
|
||||
func UNION_ALL(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement {
|
||||
return jet.UNION_ALL(lhs, rhs, toJetSelects(selects...)...)
|
||||
}
|
||||
|
||||
func INTERSECT(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement {
|
||||
return jet.INTERSECT(lhs, rhs, toJetSelects(selects...)...)
|
||||
}
|
||||
|
||||
func INTERSECT_ALL(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement {
|
||||
return jet.INTERSECT_ALL(lhs, rhs, toJetSelects(selects...)...)
|
||||
}
|
||||
|
||||
func toJetSelects(selects ...SelectStatement) []jet.SelectStatement {
|
||||
ret := []jet.SelectStatement{}
|
||||
|
||||
for _, sel := range selects {
|
||||
ret = append(ret, sel)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type SelectLock jet.SelectLock
|
||||
|
||||
var (
|
||||
UPDATE = jet.NewSelectLock("UPDATE")
|
||||
NO_KEY_UPDATE = jet.NewSelectLock("NO KEY UPDATE")
|
||||
SHARE = jet.NewSelectLock("SHARE")
|
||||
KEY_SHARE = jet.NewSelectLock("KEY SHARE")
|
||||
)
|
||||
9
postgres/postgres_table.go
Normal file
9
postgres/postgres_table.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
type Table jet.Table
|
||||
|
||||
func NewTable(schemaName, name string, columns ...jet.Column) Table {
|
||||
return jet.NewTable(Dialect, schemaName, name, columns...)
|
||||
}
|
||||
|
|
@ -1,55 +1,44 @@
|
|||
package postgres
|
||||
|
||||
import "github.com/go-jet/jet"
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
type ColumnBool jet.ColumnBool
|
||||
type BoolExpression jet.BoolExpression
|
||||
|
||||
var BoolColumn = jet.BoolColumn
|
||||
var Bool = jet.Bool
|
||||
|
||||
type ColumnString jet.ColumnString
|
||||
type StringExpression jet.StringExpression
|
||||
|
||||
var StringColumn = jet.StringColumn
|
||||
var String = jet.String
|
||||
|
||||
type ColumnInteger jet.ColumnInteger
|
||||
type IntegerExpression jet.IntegerExpression
|
||||
|
||||
var IntegerColumn = jet.IntegerColumn
|
||||
var Int = jet.Int
|
||||
|
||||
type ColumnFloat jet.ColumnFloat
|
||||
type FloatExpression jet.FloatExpression
|
||||
|
||||
var FloatColumn = jet.FloatColumn
|
||||
var Float = jet.Float
|
||||
|
||||
var FloatExp = jet.FloatExp
|
||||
|
||||
type ColumnDate jet.ColumnDate
|
||||
type DateExpression jet.DateExpression
|
||||
|
||||
var DateColumn = jet.DateColumn
|
||||
var Date = func(year, month, day int) DateExpression {
|
||||
return CAST(jet.Date(year, month, day)).AS_DATE()
|
||||
}
|
||||
|
||||
type ColumnDateTime jet.ColumnTimestamp
|
||||
type DateTimeExpression jet.TimestampExpression
|
||||
|
||||
var DateTimeColumn = jet.TimestampColumn
|
||||
var DateTime = func(year, month, day int) DateExpression {
|
||||
return CAST(jet.Date(year, month, day)).AS_DATE()
|
||||
}
|
||||
|
||||
type TimeExpression jet.TimeExpression
|
||||
type ColumnTime jet.ColumnTime
|
||||
|
||||
var TimeColumn = jet.TimeColumn
|
||||
var Time = func(hour, minute, second, milliseconds int) TimeExpression {
|
||||
return CAST(jet.Time(hour, minute, second, milliseconds)).AS_TIME()
|
||||
}
|
||||
|
||||
var TimeExp = jet.TimeExp
|
||||
|
||||
type TimezExpression jet.TimezExpression
|
||||
|
|
@ -61,9 +50,7 @@ type ColumnTimestamp jet.ColumnTimestamp
|
|||
type TimestampExpression jet.TimestampExpression
|
||||
|
||||
var TimestampColumn = jet.TimestampColumn
|
||||
var Timestamp = func(year, month, day, hour, minute, second, milliseconds int) TimestampExpression {
|
||||
return CAST(jet.Timestamp(year, month, day, hour, minute, second, milliseconds)).AS_TIMESTAMP()
|
||||
}
|
||||
|
||||
var TimestampExp = jet.TimestampExp
|
||||
|
||||
type TimestampzExpression jet.TimestampzExpression
|
||||
|
|
@ -71,34 +58,6 @@ type ColumnTimestampz jet.ColumnTimestampz
|
|||
|
||||
var TimestampzColumn = jet.TimestampzColumn
|
||||
|
||||
// ---------------- functions ------------------//
|
||||
|
||||
var MAXf = jet.MAXf
|
||||
var SUMf = jet.SUMf
|
||||
var AVG = jet.AVG
|
||||
var MINf = jet.MINf
|
||||
var COUNT = jet.COUNT
|
||||
|
||||
var CASE = jet.CASE
|
||||
type SelectTable jet.SelectTable
|
||||
|
||||
// ---------------- statements -----------------//
|
||||
|
||||
type SelectStatement jet.SelectStatement
|
||||
|
||||
var SELECT = jet.SELECT
|
||||
|
||||
var UNION = jet.UNION
|
||||
var UNION_ALL = jet.UNION_ALL
|
||||
var INTERSECT = jet.INTERSECT
|
||||
var INTERSECT_ALL = jet.INTERSECT_ALL
|
||||
|
||||
type SelectLock jet.SelectLock
|
||||
|
||||
var (
|
||||
UPDATE = jet.NewSelectLock("UPDATE")
|
||||
NO_KEY_UPDATE = jet.NewSelectLock("NO KEY UPDATE")
|
||||
SHARE = jet.NewSelectLock("SHARE")
|
||||
KEY_SHARE = jet.NewSelectLock("KEY SHARE")
|
||||
)
|
||||
|
||||
var STAR = jet.STAR
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet"
|
||||
"github.com/go-jet/jet/internal/jet"
|
||||
"gotest.tools/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var table1Col1 = IntegerColumn("col1")
|
||||
|
|
@ -15,8 +17,7 @@ var table1ColTimestampz = TimestampzColumn("col_timestampz")
|
|||
var table1ColBool = BoolColumn("col_bool")
|
||||
var table1ColDate = DateColumn("col_date")
|
||||
|
||||
var table1 = jet.NewTable(
|
||||
jet.PostgreSQL,
|
||||
var table1 = NewTable(
|
||||
"db",
|
||||
"table1",
|
||||
table1Col1,
|
||||
|
|
@ -43,8 +44,7 @@ var table2ColTimestamp = TimestampColumn("col_timestamp")
|
|||
var table2ColTimestampz = TimestampzColumn("col_timestampz")
|
||||
var table2ColDate = DateColumn("col_date")
|
||||
|
||||
var table2 = jet.NewTable(
|
||||
jet.PostgreSQL,
|
||||
var table2 = NewTable(
|
||||
"db",
|
||||
"table2",
|
||||
table2Col3,
|
||||
|
|
@ -63,10 +63,54 @@ var table2 = jet.NewTable(
|
|||
var table3Col1 = IntegerColumn("col1")
|
||||
var table3ColInt = IntegerColumn("col_int")
|
||||
var table3StrCol = StringColumn("col2")
|
||||
var table3 = jet.NewTable(
|
||||
jet.PostgreSQL,
|
||||
var table3 = NewTable(
|
||||
"db",
|
||||
"table3",
|
||||
table3Col1,
|
||||
table3ColInt,
|
||||
table3StrCol)
|
||||
|
||||
func assertClauseSerialize(t *testing.T, clause jet.Clause, query string, args ...interface{}) {
|
||||
out := jet.SqlBuilder{Dialect: Dialect}
|
||||
err := jet.Serialize(clause, jet.SelectStatementType, &out)
|
||||
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.DeepEqual(t, out.Buff.String(), query)
|
||||
assert.DeepEqual(t, out.Args, args)
|
||||
}
|
||||
|
||||
func assertClauseSerializeErr(t *testing.T, clause jet.Clause, errString string) {
|
||||
out := jet.SqlBuilder{Dialect: Dialect}
|
||||
err := jet.Serialize(clause, jet.SelectStatementType, &out)
|
||||
|
||||
//fmt.Println(out.buff.String())
|
||||
assert.Assert(t, err != nil)
|
||||
assert.Error(t, err, errString)
|
||||
}
|
||||
|
||||
func assertProjectionSerialize(t *testing.T, projection jet.Projection, query string, args ...interface{}) {
|
||||
out := jet.SqlBuilder{Dialect: Dialect}
|
||||
err := jet.SerializeForProjection(projection, jet.SelectStatementType, &out)
|
||||
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.DeepEqual(t, out.Buff.String(), query)
|
||||
assert.DeepEqual(t, out.Args, args)
|
||||
}
|
||||
|
||||
func assertStatement(t *testing.T, query jet.Statement, expectedQuery string, expectedArgs ...interface{}) {
|
||||
queryStr, args, err := query.Sql()
|
||||
assert.NilError(t, err)
|
||||
|
||||
//fmt.Println(queryStr)
|
||||
assert.Equal(t, queryStr, expectedQuery)
|
||||
assert.DeepEqual(t, args, expectedArgs)
|
||||
}
|
||||
|
||||
func assertStatementErr(t *testing.T, stmt jet.Statement, errorStr string) {
|
||||
_, _, err := stmt.Sql()
|
||||
|
||||
assert.Assert(t, err != nil)
|
||||
assert.Error(t, err, errorStr)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,54 +1,53 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var timeVar = Time(10, 20, 0, 0)
|
||||
|
||||
func TestTimeExpressionEQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.EQ(table2ColTime), "(table1.col_time = table2.col_time)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.EQ(timeVar), "(table1.col_time = $1::time without time zone)", "10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTime.EQ(table2ColTime), "(table1.col_time = table2.col_time)")
|
||||
assertClauseSerialize(t, table1ColTime.EQ(timeVar), "(table1.col_time = $1::time without time zone)", "10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimeExpressionNOT_EQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.NOT_EQ(table2ColTime), "(table1.col_time != table2.col_time)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.NOT_EQ(timeVar), "(table1.col_time != $1::time without time zone)", "10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTime.NOT_EQ(table2ColTime), "(table1.col_time != table2.col_time)")
|
||||
assertClauseSerialize(t, table1ColTime.NOT_EQ(timeVar), "(table1.col_time != $1::time without time zone)", "10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimeExpressionIS_DISTINCT_FROM(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.IS_DISTINCT_FROM(table2ColTime), "(table1.col_time IS DISTINCT FROM table2.col_time)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.IS_DISTINCT_FROM(timeVar), "(table1.col_time IS DISTINCT FROM $1::time without time zone)", "10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTime.IS_DISTINCT_FROM(table2ColTime), "(table1.col_time IS DISTINCT FROM table2.col_time)")
|
||||
assertClauseSerialize(t, table1ColTime.IS_DISTINCT_FROM(timeVar), "(table1.col_time IS DISTINCT FROM $1::time without time zone)", "10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimeExpressionIS_NOT_DISTINCT_FROM(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.IS_NOT_DISTINCT_FROM(table2ColTime), "(table1.col_time IS NOT DISTINCT FROM table2.col_time)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.IS_NOT_DISTINCT_FROM(timeVar), "(table1.col_time IS NOT DISTINCT FROM $1::time without time zone)", "10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTime.IS_NOT_DISTINCT_FROM(table2ColTime), "(table1.col_time IS NOT DISTINCT FROM table2.col_time)")
|
||||
assertClauseSerialize(t, table1ColTime.IS_NOT_DISTINCT_FROM(timeVar), "(table1.col_time IS NOT DISTINCT FROM $1::time without time zone)", "10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimeExpressionLT(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.LT(table2ColTime), "(table1.col_time < table2.col_time)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.LT(timeVar), "(table1.col_time < $1::time without time zone)", "10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTime.LT(table2ColTime), "(table1.col_time < table2.col_time)")
|
||||
assertClauseSerialize(t, table1ColTime.LT(timeVar), "(table1.col_time < $1::time without time zone)", "10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimeExpressionLT_EQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.LT_EQ(table2ColTime), "(table1.col_time <= table2.col_time)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.LT_EQ(timeVar), "(table1.col_time <= $1::time without time zone)", "10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTime.LT_EQ(table2ColTime), "(table1.col_time <= table2.col_time)")
|
||||
assertClauseSerialize(t, table1ColTime.LT_EQ(timeVar), "(table1.col_time <= $1::time without time zone)", "10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimeExpressionGT(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.GT(table2ColTime), "(table1.col_time > table2.col_time)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.GT(timeVar), "(table1.col_time > $1::time without time zone)", "10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTime.GT(table2ColTime), "(table1.col_time > table2.col_time)")
|
||||
assertClauseSerialize(t, table1ColTime.GT(timeVar), "(table1.col_time > $1::time without time zone)", "10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimeExpressionGT_EQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.GT_EQ(table2ColTime), "(table1.col_time >= table2.col_time)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTime.GT_EQ(timeVar), "(table1.col_time >= $1::time without time zone)", "10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTime.GT_EQ(table2ColTime), "(table1.col_time >= table2.col_time)")
|
||||
assertClauseSerialize(t, table1ColTime.GT_EQ(timeVar), "(table1.col_time >= $1::time without time zone)", "10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimeExp(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, TimeExp(table1ColFloat), "table1.col_float")
|
||||
jet.AssertPostgreClauseSerialize(t, TimeExp(table1ColFloat).LT(Time(1, 1, 1, 1)),
|
||||
assertClauseSerialize(t, TimeExp(table1ColFloat), "table1.col_float")
|
||||
assertClauseSerialize(t, TimeExp(table1ColFloat).LT(Time(1, 1, 1, 1)),
|
||||
"(table1.col_float < $1::time without time zone)", string("01:01:01.001"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,55 +1,54 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var timestamp = Timestamp(2000, 1, 31, 10, 20, 0, 0)
|
||||
|
||||
func TestTimestampExpressionEQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.EQ(table2ColTimestamp), "(table1.col_timestamp = table2.col_timestamp)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.EQ(timestamp),
|
||||
assertClauseSerialize(t, table1ColTimestamp.EQ(table2ColTimestamp), "(table1.col_timestamp = table2.col_timestamp)")
|
||||
assertClauseSerialize(t, table1ColTimestamp.EQ(timestamp),
|
||||
"(table1.col_timestamp = $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimestampExpressionNOT_EQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.NOT_EQ(table2ColTimestamp), "(table1.col_timestamp != table2.col_timestamp)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.NOT_EQ(timestamp), "(table1.col_timestamp != $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTimestamp.NOT_EQ(table2ColTimestamp), "(table1.col_timestamp != table2.col_timestamp)")
|
||||
assertClauseSerialize(t, table1ColTimestamp.NOT_EQ(timestamp), "(table1.col_timestamp != $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimestampExpressionIS_DISTINCT_FROM(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.IS_DISTINCT_FROM(table2ColTimestamp), "(table1.col_timestamp IS DISTINCT FROM table2.col_timestamp)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.IS_DISTINCT_FROM(timestamp), "(table1.col_timestamp IS DISTINCT FROM $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTimestamp.IS_DISTINCT_FROM(table2ColTimestamp), "(table1.col_timestamp IS DISTINCT FROM table2.col_timestamp)")
|
||||
assertClauseSerialize(t, table1ColTimestamp.IS_DISTINCT_FROM(timestamp), "(table1.col_timestamp IS DISTINCT FROM $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimestampExpressionIS_NOT_DISTINCT_FROM(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.IS_NOT_DISTINCT_FROM(table2ColTimestamp), "(table1.col_timestamp IS NOT DISTINCT FROM table2.col_timestamp)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.IS_NOT_DISTINCT_FROM(timestamp), "(table1.col_timestamp IS NOT DISTINCT FROM $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTimestamp.IS_NOT_DISTINCT_FROM(table2ColTimestamp), "(table1.col_timestamp IS NOT DISTINCT FROM table2.col_timestamp)")
|
||||
assertClauseSerialize(t, table1ColTimestamp.IS_NOT_DISTINCT_FROM(timestamp), "(table1.col_timestamp IS NOT DISTINCT FROM $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimestampExpressionLT(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.LT(table2ColTimestamp), "(table1.col_timestamp < table2.col_timestamp)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.LT(timestamp), "(table1.col_timestamp < $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTimestamp.LT(table2ColTimestamp), "(table1.col_timestamp < table2.col_timestamp)")
|
||||
assertClauseSerialize(t, table1ColTimestamp.LT(timestamp), "(table1.col_timestamp < $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimestampExpressionLT_EQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.LT_EQ(table2ColTimestamp), "(table1.col_timestamp <= table2.col_timestamp)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.LT_EQ(timestamp), "(table1.col_timestamp <= $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTimestamp.LT_EQ(table2ColTimestamp), "(table1.col_timestamp <= table2.col_timestamp)")
|
||||
assertClauseSerialize(t, table1ColTimestamp.LT_EQ(timestamp), "(table1.col_timestamp <= $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimestampExpressionGT(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.GT(table2ColTimestamp), "(table1.col_timestamp > table2.col_timestamp)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.GT(timestamp), "(table1.col_timestamp > $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTimestamp.GT(table2ColTimestamp), "(table1.col_timestamp > table2.col_timestamp)")
|
||||
assertClauseSerialize(t, table1ColTimestamp.GT(timestamp), "(table1.col_timestamp > $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimestampExpressionGT_EQ(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.GT_EQ(table2ColTimestamp), "(table1.col_timestamp >= table2.col_timestamp)")
|
||||
jet.AssertPostgreClauseSerialize(t, table1ColTimestamp.GT_EQ(timestamp), "(table1.col_timestamp >= $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
assertClauseSerialize(t, table1ColTimestamp.GT_EQ(table2ColTimestamp), "(table1.col_timestamp >= table2.col_timestamp)")
|
||||
assertClauseSerialize(t, table1ColTimestamp.GT_EQ(timestamp), "(table1.col_timestamp >= $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
}
|
||||
|
||||
func TestTimestampExp(t *testing.T) {
|
||||
jet.AssertPostgreClauseSerialize(t, TimestampExp(table1ColFloat), "table1.col_float")
|
||||
jet.AssertPostgreClauseSerialize(t, TimestampExp(table1ColFloat).LT(timestamp),
|
||||
assertClauseSerialize(t, TimestampExp(table1ColFloat), "table1.col_float")
|
||||
assertClauseSerialize(t, TimestampExp(table1ColFloat).LT(timestamp),
|
||||
"(table1.col_float < $1::timestamp without time zone)", "2000-01-31 10:20:00.000")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue