2019-08-03 14:10:47 +02:00
|
|
|
package postgres
|
|
|
|
|
|
2020-06-27 18:48:19 +02:00
|
|
|
import "github.com/go-jet/jet/v2/internal/jet"
|
2019-08-03 14:10:47 +02:00
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// Expression is common interface for all expressions.
|
|
|
|
|
// Can be Bool, Int, Float, String, Date, Time, Timez, Timestamp or Timestampz expressions.
|
2019-09-26 11:44:46 +02:00
|
|
|
type Expression = jet.Expression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// BoolExpression interface
|
2019-09-26 11:44:46 +02:00
|
|
|
type BoolExpression = jet.BoolExpression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2024-09-03 15:39:36 +02:00
|
|
|
// BoolArrayExpression interface
|
|
|
|
|
type BoolArrayExpression = jet.ArrayExpression[BoolExpression]
|
|
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// StringExpression interface
|
2019-09-26 11:44:46 +02:00
|
|
|
type StringExpression = jet.StringExpression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2025-02-28 18:23:15 +01:00
|
|
|
type ByteaExpression = jet.BlobExpression
|
|
|
|
|
|
2024-09-03 15:39:36 +02:00
|
|
|
// StringArrayExpression interface
|
|
|
|
|
type StringArrayExpression = jet.ArrayExpression[StringExpression]
|
|
|
|
|
|
2020-02-09 18:37:48 +01:00
|
|
|
// NumericExpression interface
|
|
|
|
|
type NumericExpression = jet.NumericExpression
|
|
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// IntegerExpression interface
|
2019-09-26 11:44:46 +02:00
|
|
|
type IntegerExpression = jet.IntegerExpression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2024-09-03 15:39:36 +02:00
|
|
|
// IntegerArrayExpression interface
|
|
|
|
|
type IntegerArrayExpression = jet.ArrayExpression[IntegerExpression]
|
|
|
|
|
|
2022-08-23 12:38:16 +02:00
|
|
|
// FloatExpression is interface
|
2019-09-26 11:44:46 +02:00
|
|
|
type FloatExpression = jet.FloatExpression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// TimeExpression interface
|
2019-09-26 11:44:46 +02:00
|
|
|
type TimeExpression = jet.TimeExpression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// TimezExpression interface for 'time with time zone' types
|
2019-09-26 11:44:46 +02:00
|
|
|
type TimezExpression = jet.TimezExpression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// DateExpression is interface for date types
|
2019-09-26 11:44:46 +02:00
|
|
|
type DateExpression = jet.DateExpression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// TimestampExpression interface
|
2019-09-26 11:44:46 +02:00
|
|
|
type TimestampExpression = jet.TimestampExpression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// TimestampzExpression interface
|
2019-09-26 11:44:46 +02:00
|
|
|
type TimestampzExpression = jet.TimestampzExpression
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2024-10-06 14:21:42 +02:00
|
|
|
// RowExpression interface
|
|
|
|
|
type RowExpression = jet.RowExpression
|
|
|
|
|
|
2025-03-08 19:01:37 +01:00
|
|
|
// IntervalExpression interface
|
|
|
|
|
type IntervalExpression = jet.IntervalExpression
|
|
|
|
|
|
2024-01-31 15:30:09 +01:00
|
|
|
// 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]
|
|
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// 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.
|
2019-08-06 10:29:04 +02:00
|
|
|
var BoolExp = jet.BoolExp
|
2019-08-17 14:49:35 +02:00
|
|
|
|
|
|
|
|
// IntExp is int expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as int expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
2019-08-06 10:29:04 +02:00
|
|
|
var IntExp = jet.IntExp
|
2019-08-17 14:49:35 +02:00
|
|
|
|
|
|
|
|
// FloatExp is date expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as float expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
2019-08-06 10:29:04 +02:00
|
|
|
var FloatExp = jet.FloatExp
|
2019-08-17 14:49:35 +02:00
|
|
|
|
|
|
|
|
// TimeExp is time expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as time expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
2019-08-06 10:29:04 +02:00
|
|
|
var TimeExp = jet.TimeExp
|
2019-08-17 14:49:35 +02:00
|
|
|
|
|
|
|
|
// StringExp is string expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as string expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
2019-08-13 10:16:26 +02:00
|
|
|
var StringExp = jet.StringExp
|
2019-08-17 14:49:35 +02:00
|
|
|
|
2025-02-28 18:23:15 +01:00
|
|
|
// ByteaExp is blob expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as string expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
|
|
|
|
var ByteaExp = jet.BlobExp
|
|
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// TimezExp is time with time zone expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as time with time zone expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
2019-08-06 10:29:04 +02:00
|
|
|
var TimezExp = jet.TimezExp
|
2019-08-17 14:49:35 +02:00
|
|
|
|
|
|
|
|
// DateExp is date expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as date expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
2019-08-06 10:29:04 +02:00
|
|
|
var DateExp = jet.DateExp
|
2019-08-17 14:49:35 +02:00
|
|
|
|
|
|
|
|
// TimestampExp is timestamp expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as timestamp expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
2019-08-06 10:29:04 +02:00
|
|
|
var TimestampExp = jet.TimestampExp
|
2019-08-17 14:49:35 +02:00
|
|
|
|
|
|
|
|
// TimestampzExp is timestamp with time zone expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as timestamp with time zone expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
2019-08-06 10:29:04 +02:00
|
|
|
var TimestampzExp = jet.TimestampzExp
|
|
|
|
|
|
2025-03-08 19:01:37 +01:00
|
|
|
// IntervalExp is interval expression wrapper around arbitrary expression.
|
|
|
|
|
// Allows go compiler to see any expression as interval expression.
|
|
|
|
|
// Does not add sql cast to generated sql builder output.
|
|
|
|
|
var IntervalExp = jet.IntervalExp
|
|
|
|
|
|
2024-10-06 14:21:42 +02:00
|
|
|
// 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
|
|
|
|
|
|
2024-01-31 15:30:09 +01:00
|
|
|
// 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.
|
2024-02-27 10:48:57 +01:00
|
|
|
var (
|
|
|
|
|
Int4RangeExp = jet.Int4RangeExp
|
|
|
|
|
Int8RangeExp = jet.Int8RangeExp
|
|
|
|
|
NumRangeExp = jet.NumRangeExp
|
|
|
|
|
DateRangeExp = jet.DateRangeExp
|
|
|
|
|
TsRangeExp = jet.TsRangeExp
|
|
|
|
|
TstzRangeExp = jet.TstzRangeExp
|
|
|
|
|
)
|
2024-01-31 15:30:09 +01:00
|
|
|
|
2024-07-13 17:10:26 +02:00
|
|
|
// CustomExpression is used to define custom expressions.
|
|
|
|
|
var CustomExpression = jet.CustomExpression
|
|
|
|
|
|
|
|
|
|
// Token is used to define custom token in a custom expression.
|
|
|
|
|
type Token = jet.Token
|
|
|
|
|
|
2021-05-14 12:15:35 +02:00
|
|
|
// RawArgs is type used to pass optional arguments to Raw method
|
|
|
|
|
type RawArgs = map[string]interface{}
|
|
|
|
|
|
2021-05-16 19:10:43 +02:00
|
|
|
// Raw can be used for any unsupported functions, operators or expressions.
|
|
|
|
|
// For example: Raw("current_database()")
|
|
|
|
|
// Raw helper methods for each of the postgres types
|
2021-05-14 12:15:35 +02:00
|
|
|
var (
|
|
|
|
|
Raw = jet.Raw
|
|
|
|
|
|
2025-02-28 18:23:15 +01:00
|
|
|
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
|
|
|
|
|
RawBytea = jet.RawBlob
|
|
|
|
|
|
2024-01-31 15:30:09 +01:00
|
|
|
RawNumRange = jet.RawRange[jet.NumericExpression]
|
2024-02-27 10:48:57 +01:00
|
|
|
RawInt4Range = jet.RawRange[jet.Int4Expression]
|
|
|
|
|
RawInt8Range = jet.RawRange[jet.Int8Expression]
|
2024-01-31 15:30:09 +01:00
|
|
|
RawTimestampRange = jet.RawRange[jet.TimestampExpression]
|
|
|
|
|
RawTimestampzRange = jet.RawRange[jet.TimestampzExpression]
|
|
|
|
|
RawDateRange = jet.RawRange[jet.DateExpression]
|
2021-05-14 12:15:35 +02:00
|
|
|
)
|
2019-08-06 10:29:04 +02:00
|
|
|
|
2022-01-10 16:57:57 +01:00
|
|
|
// Func can be used to call custom or unsupported database functions.
|
2020-09-29 15:29:35 -07:00
|
|
|
var Func = jet.Func
|
|
|
|
|
|
2019-08-17 14:49:35 +02:00
|
|
|
// NewEnumValue creates new named enum value
|
2019-08-06 10:29:04 +02:00
|
|
|
var NewEnumValue = jet.NewEnumValue
|
2024-03-26 15:49:17 +01:00
|
|
|
|
|
|
|
|
// BinaryOperator can be used to use custom or unsupported operators that take two operands.
|
|
|
|
|
var BinaryOperator = jet.BinaryOperator
|