Use type aliasing to forward types from internal/jet.

This commit is contained in:
go-jet 2019-09-26 11:44:46 +02:00
parent 4309b59975
commit b646dd2c99
9 changed files with 49 additions and 67 deletions

View file

@ -3,59 +3,59 @@ package mysql
import "github.com/go-jet/jet/internal/jet" import "github.com/go-jet/jet/internal/jet"
// Column is common column interface for all types of columns. // Column is common column interface for all types of columns.
type Column jet.ColumnExpression type Column = jet.ColumnExpression
// IColumnList is used to store list of columns for later reuse as projection or column list for UPDATE and INSERT statement. // IColumnList is used to store list of columns for later reuse as projection or column list for UPDATE and INSERT statement.
type IColumnList jet.IColumnList type IColumnList = jet.IColumnList
// ColumnList function returns list of columns that be used as projection or column list for UPDATE and INSERT statement. // ColumnList function returns list of columns that be used as projection or column list for UPDATE and INSERT statement.
var ColumnList = jet.ColumnList var ColumnList = jet.ColumnList
// ColumnBool is interface for SQL boolean columns. // ColumnBool is interface for SQL boolean columns.
type ColumnBool jet.ColumnBool type ColumnBool = jet.ColumnBool
// BoolColumn creates named bool column. // BoolColumn creates named bool column.
var BoolColumn = jet.BoolColumn var BoolColumn = jet.BoolColumn
// ColumnString is interface for SQL text, character, character varying // ColumnString is interface for SQL text, character, character varying
// bytea, uuid columns and enums types. // bytea, uuid columns and enums types.
type ColumnString jet.ColumnString type ColumnString = jet.ColumnString
// StringColumn creates named string column. // StringColumn creates named string column.
var StringColumn = jet.StringColumn var StringColumn = jet.StringColumn
// ColumnInteger is interface for SQL smallint, integer, bigint columns. // ColumnInteger is interface for SQL smallint, integer, bigint columns.
type ColumnInteger jet.ColumnInteger type ColumnInteger = jet.ColumnInteger
// IntegerColumn creates named integer column. // IntegerColumn creates named integer column.
var IntegerColumn = jet.IntegerColumn var IntegerColumn = jet.IntegerColumn
// ColumnFloat is interface for SQL real, numeric, decimal or double precision column. // ColumnFloat is interface for SQL real, numeric, decimal or double precision column.
type ColumnFloat jet.ColumnFloat type ColumnFloat = jet.ColumnFloat
// FloatColumn creates named float column. // FloatColumn creates named float column.
var FloatColumn = jet.FloatColumn var FloatColumn = jet.FloatColumn
// ColumnTime is interface for SQL time column. // ColumnTime is interface for SQL time column.
type ColumnTime jet.ColumnTime type ColumnTime = jet.ColumnTime
// TimeColumn creates named time column // TimeColumn creates named time column
var TimeColumn = jet.TimeColumn var TimeColumn = jet.TimeColumn
// ColumnDate is interface of SQL date columns. // ColumnDate is interface of SQL date columns.
type ColumnDate jet.ColumnDate type ColumnDate = jet.ColumnDate
// DateColumn creates named date column. // DateColumn creates named date column.
var DateColumn = jet.DateColumn var DateColumn = jet.DateColumn
// ColumnDateTime is interface of SQL timestamp columns. // ColumnDateTime is interface of SQL timestamp columns.
type ColumnDateTime jet.ColumnTimestamp type ColumnDateTime = jet.ColumnTimestamp
// DateTimeColumn creates named timestamp column // DateTimeColumn creates named timestamp column
var DateTimeColumn = jet.TimestampColumn var DateTimeColumn = jet.TimestampColumn
// ColumnTimestamp is interface of SQL timestamp columns. // ColumnTimestamp is interface of SQL timestamp columns.
type ColumnTimestamp jet.ColumnTimestamp type ColumnTimestamp = jet.ColumnTimestamp
// TimestampColumn creates named timestamp column // TimestampColumn creates named timestamp column
var TimestampColumn = jet.TimestampColumn var TimestampColumn = jet.TimestampColumn

View file

@ -4,31 +4,31 @@ import "github.com/go-jet/jet/internal/jet"
// Expression is common interface for all expressions. // Expression is common interface for all expressions.
// Can be Bool, Int, Float, String, Date, Time, Timez, Timestamp or Timestampz expressions. // Can be Bool, Int, Float, String, Date, Time, Timez, Timestamp or Timestampz expressions.
type Expression jet.Expression type Expression = jet.Expression
// BoolExpression interface // BoolExpression interface
type BoolExpression jet.BoolExpression type BoolExpression = jet.BoolExpression
// StringExpression interface // StringExpression interface
type StringExpression jet.StringExpression type StringExpression = jet.StringExpression
// IntegerExpression interface // IntegerExpression interface
type IntegerExpression jet.IntegerExpression type IntegerExpression = jet.IntegerExpression
// FloatExpression interface // FloatExpression interface
type FloatExpression jet.FloatExpression type FloatExpression = jet.FloatExpression
// TimeExpression interface // TimeExpression interface
type TimeExpression jet.TimeExpression type TimeExpression = jet.TimeExpression
// DateExpression interface // DateExpression interface
type DateExpression jet.DateExpression type DateExpression = jet.DateExpression
// DateTimeExpression interface // DateTimeExpression interface
type DateTimeExpression jet.TimestampExpression type DateTimeExpression = jet.TimestampExpression
// TimestampExpression interface // TimestampExpression interface
type TimestampExpression jet.TimestampExpression type TimestampExpression = jet.TimestampExpression
// BoolExp is bool expression wrapper around arbitrary expression. // BoolExp is bool expression wrapper around arbitrary expression.
// Allows go compiler to see any expression as bool expression. // Allows go compiler to see any expression as bool expression.

View file

@ -69,7 +69,7 @@ func newSelectStatement(table ReadableTable, projections []Projection) SelectSta
&newSelect.From, &newSelect.Where, &newSelect.GroupBy, &newSelect.Having, &newSelect.Window, &newSelect.OrderBy, &newSelect.From, &newSelect.Where, &newSelect.GroupBy, &newSelect.Having, &newSelect.Window, &newSelect.OrderBy,
&newSelect.Limit, &newSelect.Offset, &newSelect.For, &newSelect.ShareLock) &newSelect.Limit, &newSelect.Offset, &newSelect.For, &newSelect.ShareLock)
newSelect.Select.Projections = toJetProjectionList(projections) newSelect.Select.Projections = projections
newSelect.From.Table = table newSelect.From.Table = table
newSelect.Limit.Count = -1 newSelect.Limit.Count = -1
newSelect.Offset.Count = -1 newSelect.Offset.Count = -1

View file

@ -3,17 +3,7 @@ package mysql
import "github.com/go-jet/jet/internal/jet" import "github.com/go-jet/jet/internal/jet"
// Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK) // Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK)
type Statement jet.Statement type Statement = jet.Statement
// Projection is interface for all projection types. Types that can be part of, for instance SELECT clause. // Projection is interface for all projection types. Types that can be part of, for instance SELECT clause.
type Projection jet.Projection type Projection = jet.Projection
func toJetProjectionList(projections []Projection) []jet.Projection {
ret := []jet.Projection{}
for _, projection := range projections {
ret = append(ret, projection)
}
return ret
}

View file

@ -3,66 +3,66 @@ package postgres
import "github.com/go-jet/jet/internal/jet" import "github.com/go-jet/jet/internal/jet"
// Column is common column interface for all types of columns. // Column is common column interface for all types of columns.
type Column jet.ColumnExpression type Column = jet.ColumnExpression
// IColumnList is used to store list of columns for later reuse as single projection or // IColumnList is used to store list of columns for later reuse as single projection or
// column list for UPDATE and INSERT statement. // column list for UPDATE and INSERT statement.
type IColumnList jet.IColumnList type IColumnList = jet.IColumnList
// ColumnList function returns list of columns that be used as projection or column list for UPDATE and INSERT statement. // ColumnList function returns list of columns that be used as projection or column list for UPDATE and INSERT statement.
var ColumnList = jet.ColumnList var ColumnList = jet.ColumnList
// ColumnBool is interface for SQL boolean columns. // ColumnBool is interface for SQL boolean columns.
type ColumnBool jet.ColumnBool type ColumnBool = jet.ColumnBool
// BoolColumn creates named bool column. // BoolColumn creates named bool column.
var BoolColumn = jet.BoolColumn var BoolColumn = jet.BoolColumn
// ColumnString is interface for SQL text, character, character varying // ColumnString is interface for SQL text, character, character varying
// bytea, uuid columns and enums types. // bytea, uuid columns and enums types.
type ColumnString jet.ColumnString type ColumnString = jet.ColumnString
// StringColumn creates named string column. // StringColumn creates named string column.
var StringColumn = jet.StringColumn var StringColumn = jet.StringColumn
// ColumnInteger is interface for SQL smallint, integer, bigint columns. // ColumnInteger is interface for SQL smallint, integer, bigint columns.
type ColumnInteger jet.ColumnInteger type ColumnInteger = jet.ColumnInteger
// IntegerColumn creates named integer column. // IntegerColumn creates named integer column.
var IntegerColumn = jet.IntegerColumn var IntegerColumn = jet.IntegerColumn
// ColumnFloat is interface for SQL real, numeric, decimal or double precision column. // ColumnFloat is interface for SQL real, numeric, decimal or double precision column.
type ColumnFloat jet.ColumnFloat type ColumnFloat = jet.ColumnFloat
// FloatColumn creates named float column. // FloatColumn creates named float column.
var FloatColumn = jet.FloatColumn var FloatColumn = jet.FloatColumn
// ColumnDate is interface of SQL date columns. // ColumnDate is interface of SQL date columns.
type ColumnDate jet.ColumnDate type ColumnDate = jet.ColumnDate
// DateColumn creates named date column. // DateColumn creates named date column.
var DateColumn = jet.DateColumn var DateColumn = jet.DateColumn
// ColumnTime is interface for SQL time column. // ColumnTime is interface for SQL time column.
type ColumnTime jet.ColumnTime type ColumnTime = jet.ColumnTime
// TimeColumn creates named time column // TimeColumn creates named time column
var TimeColumn = jet.TimeColumn var TimeColumn = jet.TimeColumn
// ColumnTimez is interface of SQL time with time zone columns. // ColumnTimez is interface of SQL time with time zone columns.
type ColumnTimez jet.ColumnTimez type ColumnTimez = jet.ColumnTimez
// TimezColumn creates named time with time zone column. // TimezColumn creates named time with time zone column.
var TimezColumn = jet.TimezColumn var TimezColumn = jet.TimezColumn
// ColumnTimestamp is interface of SQL timestamp columns. // ColumnTimestamp is interface of SQL timestamp columns.
type ColumnTimestamp jet.ColumnTimestamp type ColumnTimestamp = jet.ColumnTimestamp
// TimestampColumn creates named timestamp column // TimestampColumn creates named timestamp column
var TimestampColumn = jet.TimestampColumn var TimestampColumn = jet.TimestampColumn
// ColumnTimestampz is interface of SQL timestamp with timezone columns. // ColumnTimestampz is interface of SQL timestamp with timezone columns.
type ColumnTimestampz jet.ColumnTimestampz type ColumnTimestampz = jet.ColumnTimestampz
// TimestampzColumn creates named timestamp with time zone column. // TimestampzColumn creates named timestamp with time zone column.
var TimestampzColumn = jet.TimestampzColumn var TimestampzColumn = jet.TimestampzColumn

View file

@ -4,34 +4,34 @@ import "github.com/go-jet/jet/internal/jet"
// Expression is common interface for all expressions. // Expression is common interface for all expressions.
// Can be Bool, Int, Float, String, Date, Time, Timez, Timestamp or Timestampz expressions. // Can be Bool, Int, Float, String, Date, Time, Timez, Timestamp or Timestampz expressions.
type Expression jet.Expression type Expression = jet.Expression
// BoolExpression interface // BoolExpression interface
type BoolExpression jet.BoolExpression type BoolExpression = jet.BoolExpression
// StringExpression interface // StringExpression interface
type StringExpression jet.StringExpression type StringExpression = jet.StringExpression
// IntegerExpression interface // IntegerExpression interface
type IntegerExpression jet.IntegerExpression type IntegerExpression = jet.IntegerExpression
//FloatExpression is interface //FloatExpression is interface
type FloatExpression jet.FloatExpression type FloatExpression = jet.FloatExpression
// TimeExpression interface // TimeExpression interface
type TimeExpression jet.TimeExpression type TimeExpression = jet.TimeExpression
// TimezExpression interface for 'time with time zone' types // TimezExpression interface for 'time with time zone' types
type TimezExpression jet.TimezExpression type TimezExpression = jet.TimezExpression
// DateExpression is interface for date types // DateExpression is interface for date types
type DateExpression jet.DateExpression type DateExpression = jet.DateExpression
// TimestampExpression interface // TimestampExpression interface
type TimestampExpression jet.TimestampExpression type TimestampExpression = jet.TimestampExpression
// TimestampzExpression interface // TimestampzExpression interface
type TimestampzExpression jet.TimestampzExpression type TimestampzExpression = jet.TimestampzExpression
// BoolExp is bool expression wrapper around arbitrary expression. // BoolExp is bool expression wrapper around arbitrary expression.
// Allows go compiler to see any expression as bool expression. // Allows go compiler to see any expression as bool expression.

View file

@ -75,7 +75,7 @@ func newSelectStatement(table ReadableTable, projections []Projection) SelectSta
&newSelect.From, &newSelect.Where, &newSelect.GroupBy, &newSelect.Having, &newSelect.Window, &newSelect.OrderBy, &newSelect.From, &newSelect.Where, &newSelect.GroupBy, &newSelect.Having, &newSelect.Window, &newSelect.OrderBy,
&newSelect.Limit, &newSelect.Offset, &newSelect.For) &newSelect.Limit, &newSelect.Offset, &newSelect.For)
newSelect.Select.Projections = toJetProjectionList(projections) newSelect.Select.Projections = projections
newSelect.From.Table = table newSelect.From.Table = table
newSelect.Limit.Count = -1 newSelect.Limit.Count = -1
newSelect.Offset.Count = -1 newSelect.Offset.Count = -1

View file

@ -3,17 +3,7 @@ package postgres
import "github.com/go-jet/jet/internal/jet" import "github.com/go-jet/jet/internal/jet"
// Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK) // Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK)
type Statement jet.Statement type Statement = jet.Statement
// Projection is interface for all projection types. Types that can be part of, for instance SELECT clause. // Projection is interface for all projection types. Types that can be part of, for instance SELECT clause.
type Projection jet.Projection type Projection = jet.Projection
func toJetProjectionList(projections []Projection) []jet.Projection {
ret := []jet.Projection{}
for _, projection := range projections {
ret = append(ret, projection)
}
return ret
}

View file

@ -85,9 +85,11 @@ func TestDeleteQueryContext(t *testing.T) {
func TestDeleteExecContext(t *testing.T) { func TestDeleteExecContext(t *testing.T) {
initForDeleteTest(t) initForDeleteTest(t)
list := []Expression{String("Gmail"), String("Outlook")}
deleteStmt := Link. deleteStmt := Link.
DELETE(). DELETE().
WHERE(Link.Name.IN(String("Gmail"), String("Outlook"))) WHERE(Link.Name.IN(list...))
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond)
defer cancel() defer cancel()