Package structure refactor.
This commit is contained in:
parent
3d8e872336
commit
23fd973699
125 changed files with 2401 additions and 1818 deletions
89
mysql/bool_expression_test.go
Normal file
89
mysql/bool_expression_test.go
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBoolExpressionEQ(t *testing.T) {
|
||||
assertClauseSerializeErr(t, table1ColBool.EQ(nil), "jet: nil rhs")
|
||||
|
||||
assertClauseSerialize(t, table1ColBool.EQ(table2ColBool), "(table1.col_bool = table2.col_bool)")
|
||||
assertClauseSerialize(t, table1ColBool.EQ(Bool(true)), "(table1.col_bool = ?)", true)
|
||||
}
|
||||
|
||||
func TestBoolExpressionNOT_EQ(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColBool.NOT_EQ(table2ColBool), "(table1.col_bool != table2.col_bool)")
|
||||
assertClauseSerialize(t, table1ColBool.NOT_EQ(Bool(true)), "(table1.col_bool != ?)", true)
|
||||
}
|
||||
|
||||
func TestBoolExpressionIS_DISTINCT_FROM(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColBool.IS_DISTINCT_FROM(table2ColBool), "(NOT table1.col_bool <=> table2.col_bool)")
|
||||
assertClauseSerialize(t, table1ColBool.IS_DISTINCT_FROM(Bool(false)), "(NOT table1.col_bool <=> ?)", false)
|
||||
}
|
||||
|
||||
func TestBoolExpressionIS_NOT_DISTINCT_FROM(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColBool.IS_NOT_DISTINCT_FROM(table2ColBool), "(table1.col_bool <=> table2.col_bool)")
|
||||
assertClauseSerialize(t, table1ColBool.IS_NOT_DISTINCT_FROM(Bool(false)), "(table1.col_bool <=> ?)", false)
|
||||
|
||||
}
|
||||
|
||||
func TestBoolExpressionIS_TRUE(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColBool.IS_TRUE(), "table1.col_bool IS TRUE")
|
||||
assertClauseSerialize(t, (Int(2).EQ(table1ColInt)).IS_TRUE(),
|
||||
`(? = table1.col_int) IS TRUE`, int64(2))
|
||||
assertClauseSerialize(t, (Int(2).EQ(table1ColInt)).IS_TRUE().AND(Int(4).EQ(table2ColInt)),
|
||||
`((? = table1.col_int) IS TRUE AND (? = table2.col_int))`, int64(2), int64(4))
|
||||
}
|
||||
|
||||
func TestBoolExpressionIS_NOT_TRUE(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColBool.IS_NOT_TRUE(), "table1.col_bool IS NOT TRUE")
|
||||
}
|
||||
|
||||
func TestBoolExpressionIS_FALSE(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColBool.IS_FALSE(), "table1.col_bool IS FALSE")
|
||||
}
|
||||
|
||||
func TestBoolExpressionIS_NOT_FALSE(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColBool.IS_NOT_FALSE(), "table1.col_bool IS NOT FALSE")
|
||||
}
|
||||
|
||||
func TestBoolExpressionIS_UNKNOWN(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColBool.IS_UNKNOWN(), "table1.col_bool IS UNKNOWN")
|
||||
}
|
||||
|
||||
func TestBoolExpressionIS_NOT_UNKNOWN(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColBool.IS_NOT_UNKNOWN(), "table1.col_bool IS NOT UNKNOWN")
|
||||
}
|
||||
|
||||
func TestBinaryBoolExpressionAsProjection(t *testing.T) {
|
||||
boolExpression := Int(2).EQ(Int(3))
|
||||
|
||||
assertProjectionSerialize(t, boolExpression, "? = ?", int64(2), int64(3))
|
||||
assertProjectionSerialize(t, boolExpression.AS("alias_eq_expression"),
|
||||
`(? = ?) AS "alias_eq_expression"`, int64(2), int64(3))
|
||||
}
|
||||
|
||||
func TestBoolLiteral(t *testing.T) {
|
||||
assertClauseSerialize(t, Bool(true), "?", true)
|
||||
assertClauseSerialize(t, Bool(false), "?", false)
|
||||
}
|
||||
|
||||
//
|
||||
//func TestExists(t *testing.T) {
|
||||
//
|
||||
// assertClauseSerialize(t, EXISTS(
|
||||
// table2.
|
||||
// SELECT(Int(1)).
|
||||
// WHERE(table1Col1.EQ(table2Col3)),
|
||||
// ),
|
||||
// `(EXISTS (
|
||||
// SELECT ?
|
||||
// FROM db.table2
|
||||
// WHERE table1.col1 = table2.col3
|
||||
//))`, int64(1))
|
||||
//}
|
||||
//
|
||||
//func TestBoolExp(t *testing.T) {
|
||||
// assertClauseSerialize(t, BoolExp(String("true")), "?", "true")
|
||||
// assertClauseSerialize(t, BoolExp(String("true")).IS_TRUE(), "? IS TRUE", "true")
|
||||
//}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet"
|
||||
"github.com/go-jet/jet/internal/jet"
|
||||
)
|
||||
|
||||
type cast interface {
|
||||
9
mysql/cast_test.go
Normal file
9
mysql/cast_test.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCAST_AS_DATE(t *testing.T) {
|
||||
assertClauseSerialize(t, CAST(Int(22)).AS_DATE(), `CAST(? AS DATE)`, int64(22))
|
||||
}
|
||||
9
mysql/column.go
Normal file
9
mysql/column.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package mysql
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
type Column jet.Column
|
||||
|
||||
type IColumnList jet.IColumnList
|
||||
|
||||
var ColumnList = jet.ColumnList
|
||||
139
mysql/dialect.go
Normal file
139
mysql/dialect.go
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/go-jet/jet/internal/jet"
|
||||
)
|
||||
|
||||
var Dialect = NewDialect()
|
||||
|
||||
func NewDialect() jet.Dialect {
|
||||
|
||||
serializeOverrides := map[string]jet.SerializeOverride{}
|
||||
serializeOverrides["IS DISTINCT FROM"] = mysql_IS_DISTINCT_FROM
|
||||
serializeOverrides["IS NOT DISTINCT FROM"] = mysql_IS_NOT_DISTINCT_FROM
|
||||
serializeOverrides["/"] = mysql_DIVISION
|
||||
serializeOverrides["#"] = mysql_BIT_XOR
|
||||
|
||||
mySQLDialectParams := jet.DialectParams{
|
||||
Name: "MySQL",
|
||||
PackageName: "mysql",
|
||||
SerializeOverrides: serializeOverrides,
|
||||
AliasQuoteChar: '"',
|
||||
IdentifierQuoteChar: '`',
|
||||
ArgumentPlaceholder: func(int) string {
|
||||
return "?"
|
||||
},
|
||||
UpdateAssigment: mysqlUpdateAssigment,
|
||||
SupportsReturning: false,
|
||||
}
|
||||
|
||||
return jet.NewDialect(mySQLDialectParams)
|
||||
}
|
||||
|
||||
func mysqlUpdateAssigment(columns []jet.IColumn, values []jet.Clause, out *jet.SqlBuilder) (err error) {
|
||||
|
||||
if len(columns) != len(values) {
|
||||
return errors.New("jet: mismatch in numers of columns and values")
|
||||
}
|
||||
|
||||
for i, column := range columns {
|
||||
if i > 0 {
|
||||
out.WriteString(", ")
|
||||
}
|
||||
|
||||
out.WriteString(column.Name())
|
||||
|
||||
out.WriteString(" = ")
|
||||
|
||||
if err = jet.Serialize(values[i], jet.UpdateStatementType, out); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func mysql_BIT_XOR(expressions ...jet.Expression) jet.SerializeFunc {
|
||||
return func(statement jet.StatementType, out *jet.SqlBuilder, options ...jet.SerializeOption) error {
|
||||
if len(expressions) != 2 {
|
||||
return errors.New("jet: invalid number of expressions for operator")
|
||||
}
|
||||
|
||||
lhs := expressions[0]
|
||||
rhs := expressions[1]
|
||||
|
||||
if err := jet.Serialize(lhs, statement, out, options...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.WriteString("^")
|
||||
|
||||
if err := jet.Serialize(rhs, statement, out, options...); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func mysql_DIVISION(expressions ...jet.Expression) jet.SerializeFunc {
|
||||
return func(statement jet.StatementType, out *jet.SqlBuilder, options ...jet.SerializeOption) error {
|
||||
if len(expressions) != 2 {
|
||||
return errors.New("jet: invalid number of expressions for operator")
|
||||
}
|
||||
|
||||
lhs := expressions[0]
|
||||
rhs := expressions[1]
|
||||
|
||||
if err := jet.Serialize(lhs, statement, out, options...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, isLhsInt := lhs.(IntegerExpression)
|
||||
_, isRhsInt := rhs.(IntegerExpression)
|
||||
|
||||
if isLhsInt && isRhsInt {
|
||||
out.WriteString("DIV")
|
||||
} else {
|
||||
out.WriteString("/")
|
||||
}
|
||||
|
||||
if err := jet.Serialize(rhs, statement, out, options...); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func mysql_IS_NOT_DISTINCT_FROM(expressions ...jet.Expression) jet.SerializeFunc {
|
||||
return func(statement jet.StatementType, out *jet.SqlBuilder, options ...jet.SerializeOption) error {
|
||||
if len(expressions) != 2 {
|
||||
return errors.New("jet: invalid number of expressions for operator")
|
||||
}
|
||||
if err := jet.Serialize(expressions[0], statement, out); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.WriteString("<=>")
|
||||
|
||||
if err := jet.Serialize(expressions[1], statement, out); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func mysql_IS_DISTINCT_FROM(expressions ...jet.Expression) jet.SerializeFunc {
|
||||
return func(statement jet.StatementType, out *jet.SqlBuilder, options ...jet.SerializeOption) error {
|
||||
out.WriteString("NOT")
|
||||
|
||||
err := mysql_IS_NOT_DISTINCT_FROM(expressions...)(statement, out, options...)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
21
mysql/expressions.go
Normal file
21
mysql/expressions.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package mysql
|
||||
|
||||
import "github.com/go-jet/jet/internal/jet"
|
||||
|
||||
type Expression jet.Expression
|
||||
|
||||
type BoolExpression jet.BoolExpression
|
||||
|
||||
type StringExpression jet.StringExpression
|
||||
|
||||
type IntegerExpression jet.IntegerExpression
|
||||
|
||||
type FloatExpression jet.FloatExpression
|
||||
|
||||
type DateExpression jet.DateExpression
|
||||
|
||||
type DateTimeExpression jet.TimestampExpression
|
||||
|
||||
type TimestampExpression jet.TimestampExpression
|
||||
|
||||
type TimeExpression jet.TimeExpression
|
||||
107
mysql/integer_expression_test.go
Normal file
107
mysql/integer_expression_test.go
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIntegerExpressionEQ(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.EQ(table2ColInt), "(table1.col_int = table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.EQ(Int(11)), "(table1.col_int = ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntegerExpressionNOT_EQ(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.NOT_EQ(table2ColInt), "(table1.col_int != table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.NOT_EQ(Int(11)), "(table1.col_int != ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntegerExpressionGT(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.GT(table2ColInt), "(table1.col_int > table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.GT(Int(11)), "(table1.col_int > ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntegerExpressionGT_EQ(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.GT_EQ(table2ColInt), "(table1.col_int >= table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.GT_EQ(Int(11)), "(table1.col_int >= ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntegerExpressionLT(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.LT(table2ColInt), "(table1.col_int < table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.LT(Int(11)), "(table1.col_int < ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntegerExpressionLT_EQ(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.LT_EQ(table2ColInt), "(table1.col_int <= table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.LT_EQ(Int(11)), "(table1.col_int <= ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntegerExpressionADD(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.ADD(table2ColInt), "(table1.col_int + table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.ADD(Int(11)), "(table1.col_int + ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntegerExpressionSUB(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.SUB(table2ColInt), "(table1.col_int - table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.SUB(Int(11)), "(table1.col_int - ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntegerExpressionMUL(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.MUL(table2ColInt), "(table1.col_int * table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.MUL(Int(11)), "(table1.col_int * ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntegerExpressionDIV(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.DIV(table2ColInt), "(table1.col_int DIV table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.DIV(Int(11)), "(table1.col_int DIV ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntExpressionMOD(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.MOD(table2ColInt), "(table1.col_int % table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.MOD(Int(11)), "(table1.col_int % ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntExpressionPOW(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.POW(table2ColInt), "POW(table1.col_int, table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.POW(Int(11)), "POW(table1.col_int, ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntExpressionBIT_NOT(t *testing.T) {
|
||||
assertClauseSerialize(t, BIT_NOT(table2ColInt), "(~ table2.col_int)")
|
||||
assertClauseSerialize(t, BIT_NOT(Int(11)), "(~ ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntExpressionBIT_AND(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.BIT_AND(table2ColInt), "(table1.col_int & table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.BIT_AND(Int(11)), "(table1.col_int & ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntExpressionBIT_OR(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.BIT_OR(table2ColInt), "(table1.col_int | table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.BIT_OR(Int(11)), "(table1.col_int | ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntExpressionBIT_XOR(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.BIT_XOR(table2ColInt), "(table1.col_int ^ table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.BIT_XOR(Int(11)), "(table1.col_int ^ ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntExpressionBIT_SHIFT_LEFT(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.BIT_SHIFT_LEFT(table2ColInt), "(table1.col_int << table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.BIT_SHIFT_LEFT(Int(11)), "(table1.col_int << ?)", int64(11))
|
||||
}
|
||||
|
||||
func TestIntExpressionBIT_SHIFT_RIGHT(t *testing.T) {
|
||||
assertClauseSerialize(t, table1ColInt.BIT_SHIFT_RIGHT(table2ColInt), "(table1.col_int >> table2.col_int)")
|
||||
assertClauseSerialize(t, table1ColInt.BIT_SHIFT_RIGHT(Int(11)), "(table1.col_int >> ?)", int64(11))
|
||||
}
|
||||
|
||||
//
|
||||
//func TestIntExpressionIntExp(t *testing.T) {
|
||||
// assertClauseSerialize(t, IntExp(table1ColFloat), "table1.col_float")
|
||||
// assertClauseSerialize(t, IntExp(table1ColFloat.ADD(table2ColFloat)).ADD(Int(11)),
|
||||
// "((table1.col_float + table2.col_float) + ?)", int64(11))
|
||||
//}
|
||||
|
||||
func TestIntExpression_MINUSi(t *testing.T) {
|
||||
assertClauseSerialize(t, MINUSi(table2ColInt), "(- table2.col_int)")
|
||||
assertClauseSerialize(t, MINUSi(Int(3)), "(- ?)", int64(3))
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCAST_AS_DATE(t *testing.T) {
|
||||
|
||||
jet.AssertMySQLClauseSerialize(t, CAST(Int(22)).AS_DATE(), `CAST(? AS DATE)`, int64(22))
|
||||
}
|
||||
9
mysql/table.go
Normal file
9
mysql/table.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package mysql
|
||||
|
||||
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...)
|
||||
}
|
||||
104
mysql/testutils.go
Normal file
104
mysql/testutils.go
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/internal/jet"
|
||||
"gotest.tools/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var table1Col1 = IntegerColumn("col1")
|
||||
var table1ColInt = IntegerColumn("col_int")
|
||||
var table1ColFloat = FloatColumn("col_float")
|
||||
var table1Col3 = IntegerColumn("col3")
|
||||
var table1ColTimestamp = TimestampColumn("col_timestamp")
|
||||
var table1ColBool = BoolColumn("col_bool")
|
||||
var table1ColDate = DateColumn("col_date")
|
||||
|
||||
var table1 = NewTable(
|
||||
"db",
|
||||
"table1",
|
||||
table1Col1,
|
||||
table1ColInt,
|
||||
table1ColFloat,
|
||||
table1Col3,
|
||||
table1ColBool,
|
||||
table1ColDate,
|
||||
table1ColTimestamp,
|
||||
)
|
||||
|
||||
var table2Col3 = IntegerColumn("col3")
|
||||
var table2Col4 = IntegerColumn("col4")
|
||||
var table2ColInt = IntegerColumn("col_int")
|
||||
var table2ColFloat = FloatColumn("col_float")
|
||||
var table2ColStr = StringColumn("col_str")
|
||||
var table2ColBool = BoolColumn("col_bool")
|
||||
var table2ColTimestamp = TimestampColumn("col_timestamp")
|
||||
var table2ColDate = DateColumn("col_date")
|
||||
|
||||
var table2 = NewTable(
|
||||
"db",
|
||||
"table2",
|
||||
table2Col3,
|
||||
table2Col4,
|
||||
table2ColInt,
|
||||
table2ColFloat,
|
||||
table2ColStr,
|
||||
table2ColBool,
|
||||
table2ColDate,
|
||||
table2ColTimestamp,
|
||||
)
|
||||
|
||||
var table3Col1 = IntegerColumn("col1")
|
||||
var table3ColInt = IntegerColumn("col_int")
|
||||
var table3StrCol = StringColumn("col2")
|
||||
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,53 +1,42 @@
|
|||
package mysql
|
||||
|
||||
import "github.com/go-jet/jet"
|
||||
|
||||
type Expression jet.Expression
|
||||
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
|
||||
|
||||
type ColumnDate jet.ColumnDate
|
||||
type DateExpression jet.DateExpression
|
||||
|
||||
var DateColumn = jet.DateColumn
|
||||
var Date = jet.Date
|
||||
|
||||
type ColumnDateTime jet.ColumnTimestamp
|
||||
type DateTimeExpression jet.TimestampExpression
|
||||
|
||||
var DateTimeColumn = jet.TimestampColumn
|
||||
var DateTime = jet.Timestamp
|
||||
|
||||
type ColumnTimestamp jet.ColumnTimestamp
|
||||
type TimestampExpression jet.TimestampExpression
|
||||
|
||||
var TimestampColumn = jet.TimestampColumn
|
||||
var Timestamp = jet.Timestamp
|
||||
|
||||
type TimeExpression jet.TimeExpression
|
||||
|
||||
// ----------------- FUNCTIONS ----------------------//
|
||||
|
||||
var ABSf = jet.ABSf
|
||||
Loading…
Add table
Add a link
Reference in a new issue