Range types implemented
plus and minus infinity keyword tests implemented range table tests added skip cockroach db added select test case added for range fields generator modified to generate correct types generator tests modified to include sample range table model and template generators modified to support range fields returning the T in UPPER and LOWER functions raw ranges implemented bounds set as optional dep modified dependencies modified and issue fixed range expression with templates implemented rangeExpression change to make it more type safe third parameter of constructor function fixed literals removed, functions added tests modified constructor functions used for creating range expressions NumRange converted to a constructor function from literal range_lower and range_upper renamed to lower_bound and upper_bound range literal removed PlusInfinity and MinusInfinity implemented int4 and int8 castings added issues fixed and tests checked number, ts, tstz literal and cast implemented date range literal expression modified and raw function used parent type converted from RangeExpression to Expression range type implemented for postgres range column type, function and literal expression implemented CONTAINS and OVERLAP operations added for range expressions range expressions implemented
This commit is contained in:
parent
a9cbf94d68
commit
893567daca
20 changed files with 1062 additions and 19 deletions
|
|
@ -65,6 +65,42 @@ type ColumnTimestampz = jet.ColumnTimestampz
|
|||
// TimestampzColumn creates named timestamp with time zone column.
|
||||
var TimestampzColumn = jet.TimestampzColumn
|
||||
|
||||
// ColumnDateRange is interface of SQL date range column
|
||||
type ColumnDateRange = jet.ColumnRange[DateExpression]
|
||||
|
||||
// DateRangeColumn creates named range with range column
|
||||
var DateRangeColumn = jet.RangeColumn[DateExpression]
|
||||
|
||||
// ColumnNumericRange is interface of SQL numeric range column
|
||||
type ColumnNumericRange = jet.ColumnRange[NumericExpression]
|
||||
|
||||
// NumericRangeColumn creates named range with range column
|
||||
var NumericRangeColumn = jet.RangeColumn[NumericExpression]
|
||||
|
||||
// ColumnTimestampRange is interface of SQL timestamp range column
|
||||
type ColumnTimestampRange = jet.ColumnRange[TimestampExpression]
|
||||
|
||||
// TimestampRangeColumn creates named range with range column
|
||||
var TimestampRangeColumn = jet.RangeColumn[TimestampExpression]
|
||||
|
||||
// ColumnTimestampzRange is interface of SQL timestamp range column
|
||||
type ColumnTimestampzRange = jet.ColumnRange[TimestampzExpression]
|
||||
|
||||
// TimestampzRangeColumn creates named range with range column
|
||||
var TimestampzRangeColumn = jet.RangeColumn[TimestampzExpression]
|
||||
|
||||
// ColumnInt4Range is interface of SQL int range column
|
||||
type ColumnInt4Range = jet.ColumnRange[IntegerExpression]
|
||||
|
||||
// Int4RangeColumn creates named range with range column
|
||||
var Int4RangeColumn = jet.RangeColumn[IntegerExpression]
|
||||
|
||||
// ColumnInt8Range is interface of SQL int range column
|
||||
type ColumnInt8Range = jet.ColumnRange[IntegerExpression]
|
||||
|
||||
// Int8RangeColumn creates named range with range column
|
||||
var Int8RangeColumn = jet.RangeColumn[IntegerExpression]
|
||||
|
||||
//------------------------------------------------------//
|
||||
|
||||
// ColumnInterval is interface of PostgreSQL interval columns.
|
||||
|
|
|
|||
|
|
@ -36,6 +36,24 @@ type TimestampExpression = jet.TimestampExpression
|
|||
// TimestampzExpression interface
|
||||
type TimestampzExpression = jet.TimestampzExpression
|
||||
|
||||
// DateRange Expression interface
|
||||
type DateRange = jet.Range[DateExpression]
|
||||
|
||||
// TimestampRange Expression interface
|
||||
type TimestampRange = jet.Range[TimestampExpression]
|
||||
|
||||
// TimestampzRange Expression interface
|
||||
type TimestampzRange = jet.Range[TimestampzExpression]
|
||||
|
||||
// NumericRange Expression interface
|
||||
type NumericRange = jet.Range[NumericExpression]
|
||||
|
||||
// Int4Range Expression interface
|
||||
type Int4Range = jet.Range[IntegerExpression]
|
||||
|
||||
// Int8Range Expression interface
|
||||
type Int8Range = jet.Range[IntegerExpression]
|
||||
|
||||
// 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.
|
||||
|
|
@ -81,6 +99,13 @@ var TimestampExp = jet.TimestampExp
|
|||
// Does not add sql cast to generated sql builder output.
|
||||
var TimestampzExp = jet.TimestampzExp
|
||||
|
||||
// RangeExp is range expression wrapper around arbitrary expression.
|
||||
// Allows go compiler to see any expression as range expression.
|
||||
// Does not add sql cast to generated sql builder output.
|
||||
func RangeExp[T Expression](expression T) jet.Range[T] {
|
||||
return jet.RangeExp[T](expression)
|
||||
}
|
||||
|
||||
// RawArgs is type used to pass optional arguments to Raw method
|
||||
type RawArgs = map[string]interface{}
|
||||
|
||||
|
|
@ -90,15 +115,21 @@ type RawArgs = map[string]interface{}
|
|||
var (
|
||||
Raw = jet.Raw
|
||||
|
||||
RawBool = jet.RawBool
|
||||
RawInt = jet.RawInt
|
||||
RawFloat = jet.RawFloat
|
||||
RawString = jet.RawString
|
||||
RawTime = jet.RawTime
|
||||
RawTimez = jet.RawTimez
|
||||
RawTimestamp = jet.RawTimestamp
|
||||
RawTimestampz = jet.RawTimestampz
|
||||
RawDate = jet.RawDate
|
||||
RawBool = jet.RawBool
|
||||
RawInt = jet.RawInt
|
||||
RawFloat = jet.RawFloat
|
||||
RawString = jet.RawString
|
||||
RawTime = jet.RawTime
|
||||
RawTimez = jet.RawTimez
|
||||
RawTimestamp = jet.RawTimestamp
|
||||
RawTimestampz = jet.RawTimestampz
|
||||
RawDate = jet.RawDate
|
||||
RawNumRange = jet.RawRange[jet.NumericExpression]
|
||||
RawInt4Range = jet.RawRange[jet.IntegerExpression]
|
||||
RawInt8Range = jet.RawRange[jet.IntegerExpression]
|
||||
RawTimestampRange = jet.RawRange[jet.TimestampExpression]
|
||||
RawTimestampzRange = jet.RawRange[jet.TimestampzExpression]
|
||||
RawDateRange = jet.RawRange[jet.DateExpression]
|
||||
)
|
||||
|
||||
// Func can be used to call custom or unsupported database functions.
|
||||
|
|
|
|||
|
|
@ -267,6 +267,18 @@ var TO_HEX = jet.TO_HEX
|
|||
|
||||
//----------Data Type Formatting Functions ----------------------//
|
||||
|
||||
// LOWER_BOUND returns range expressions lower bound
|
||||
func LOWER_BOUND[T Expression](expression jet.Range[T]) T {
|
||||
return jet.LOWER_BOUND[T](expression)
|
||||
}
|
||||
|
||||
// UPPER_BOUND returns range expressions upper bound
|
||||
func UPPER_BOUND[T Expression](expression jet.Range[T]) T {
|
||||
return jet.UPPER_BOUND[T](expression)
|
||||
}
|
||||
|
||||
//----------Data Type Formatting Functions ----------------------//
|
||||
|
||||
// TO_CHAR converts expression to string with format
|
||||
var TO_CHAR = jet.TO_CHAR
|
||||
|
||||
|
|
@ -421,3 +433,18 @@ var CUBE = jet.CUBE
|
|||
// It can be also used with multiple parameters to check if a set of columns is included in the current grouping set. The result
|
||||
// of the GROUPING function would then be an integer bit mask having 1’s for the arguments which have GROUPING(argument) as 1.
|
||||
var GROUPING = jet.GROUPING
|
||||
|
||||
var (
|
||||
// DATE_RANGE constructor function to create a date range
|
||||
DATE_RANGE = jet.DateRange
|
||||
// NUM_Range constructor function to create a numeric range
|
||||
NUM_Range = jet.NumRange
|
||||
// TIMESTAMP_RANGE constructor function to create a timestamp range
|
||||
TIMESTAMP_RANGE = jet.TimestampRange
|
||||
// TIMESTAMPTZ_RANGE constructor function to create a timestampz range
|
||||
TIMESTAMPTZ_RANGE = jet.TimestampzRange
|
||||
// INT4_RANGE constructor function to create a int4 range
|
||||
INT4_RANGE = jet.Int4Range
|
||||
// INT8_RANGE constructor function to create a int8 range
|
||||
INT8_RANGE = jet.Int8Range
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,4 +12,8 @@ var (
|
|||
NULL = jet.NULL
|
||||
// STAR is jet equivalent of SQL *
|
||||
STAR = jet.STAR
|
||||
// PLUS_INFINITY is jet equivalent for sql infinity
|
||||
PLUS_INFINITY = jet.PLUS_INFINITY
|
||||
// MINUS_INFINITY is jet equivalent for sql -infinity
|
||||
MINUS_INFINITY = jet.MINUS_INFINITY
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ var table1ColTimestampz = TimestampzColumn("col_timestampz")
|
|||
var table1ColBool = BoolColumn("col_bool")
|
||||
var table1ColDate = DateColumn("col_date")
|
||||
var table1ColInterval = IntervalColumn("col_interval")
|
||||
var table1ColRange = Int8RangeColumn("col_range")
|
||||
|
||||
var table1 = NewTable(
|
||||
"db",
|
||||
|
|
@ -32,6 +33,7 @@ var table1 = NewTable(
|
|||
table1ColTimestamp,
|
||||
table1ColTimestampz,
|
||||
table1ColInterval,
|
||||
table1ColRange,
|
||||
)
|
||||
|
||||
var table2Col3 = IntegerColumn("col3")
|
||||
|
|
@ -46,8 +48,9 @@ var table2ColTimestamp = TimestampColumn("col_timestamp")
|
|||
var table2ColTimestampz = TimestampzColumn("col_timestampz")
|
||||
var table2ColDate = DateColumn("col_date")
|
||||
var table2ColInterval = IntervalColumn("col_interval")
|
||||
var table2ColRange = Int8RangeColumn("col_range")
|
||||
|
||||
var table2 = NewTable("db", "table2", "", table2Col3, table2Col4, table2ColInt, table2ColFloat, table2ColStr, table2ColBool, table2ColTime, table2ColTimez, table2ColDate, table2ColTimestamp, table2ColTimestampz, table2ColInterval)
|
||||
var table2 = NewTable("db", "table2", "", table2Col3, table2Col4, table2ColInt, table2ColFloat, table2ColStr, table2ColBool, table2ColTime, table2ColTimez, table2ColDate, table2ColTimestamp, table2ColTimestampz, table2ColInterval, table2ColRange)
|
||||
|
||||
var table3Col1 = IntegerColumn("col1")
|
||||
var table3ColInt = IntegerColumn("col_int")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue