Documentation ¶
Index ¶
- Constants
- Variables
- func AreTypesHaveEqualOrHaveEqualBaseTypes(driver *Driver, customTypes []*Type, a string, b string) bool
- func BoolToInt(driver *Driver, input []byte) (output []byte, err error)
- func CastFloatToInt(driver *Driver, input []byte) (output []byte, err error)
- func CastIntToFloat(driver *Driver, input []byte) (output []byte, err error)
- func DefaultDatabaseTypeUnmarshaler(driver *Driver, typeName string, v ParamsValue) (any, error)
- func FuncMap() template.FuncMap
- func GetAffectedAndTransferringColumns(parameters map[string]Parameterizer, driver *Driver) (affectedColumnsIdx []*Column, transferringColumnsIdx []*Column, err error)
- func GetCanonicalTypeName(driver *Driver, typeName string, typeOid uint32) string
- func GetDriverAndRecord(columnValues map[string]*RawValue) (*Driver, *Record)
- func IntToBool(driver *Driver, input []byte) (output []byte, err error)
- func IsTypeAllowed(driver *Driver, allowedTypes []string, typeName string, checkInherited bool) bool
- func IsTypeAllowedWithTypeMap(driver *Driver, allowedTypes []string, typeName string, typeOid Oid, ...) bool
- func IsTypeCustom(customTypes []*Type, typeOid Oid) bool
- func NewDriver(table *Table, customTypes []*Type) (*Driver, ValidationWarnings, error)
- func NewTypeCaster(driver *Driver, inputType, outputType, castFunction string) (*TypeCaster, ValidationWarnings, error)
- func NewWhenCond(when string, driver *Driver, meta map[string]any) (*WhenCond, ValidationWarnings)
- func NoiseDateV2(r *rand.Rand, ratio time.Duration, t *time.Time) *time.Time
- func NoiseFloat(r *rand.Rand, ratio float64, value float64, precision int) float64
- func NoiseInt(r *rand.Rand, ratio float64, value int64) int64
- func PrintValidationWarnings(warns ValidationWarnings, resolvedWarnings []string, printAll bool) error
- func RandomBool(r *rand.Rand) bool
- func RandomDate(r *rand.Rand, min, max *time.Time) *time.Time
- func RandomFloat(r *rand.Rand, min, max float64, precision int) float64
- func RandomInt(r *rand.Rand, min, max int64) int64
- func RandomString(randGen *rand.Rand, minLength, maxLength int64, symbols []rune, buf []rune) string
- func Round(precision int, num float64) float64
- func ScanPointer(src, dest any) error
- func TruncateDate(part *string, t *time.Time) (*time.Time, error)
- func TryRegisterCustomTypes(typeMap *pgtype.Map, types []*Type, silent bool)
- type AttNum
- type Check
- type Cmd
- type Column
- type ColumnProperties
- func (cp *ColumnProperties) SetAffected(v bool) *ColumnProperties
- func (cp *ColumnProperties) SetAllowedColumnTypes(v ...string) *ColumnProperties
- func (cp *ColumnProperties) SetMaxLength(v int) *ColumnProperties
- func (cp *ColumnProperties) SetNullable(v bool) *ColumnProperties
- func (cp *ColumnProperties) SetSkipOnNull(v bool) *ColumnProperties
- func (cp *ColumnProperties) SetSkipOriginalData(v bool) *ColumnProperties
- func (cp *ColumnProperties) SetUnique(v bool) *ColumnProperties
- type Constraint
- type CsvApi
- func (ca *CsvApi) Clean()
- func (ca *CsvApi) Decode(ctx context.Context) (RowDriver, error)
- func (ca *CsvApi) Encode(ctx context.Context, row RowDriver) (err error)
- func (ca *CsvApi) GetRowDriverFromRecord(r *Record) (RowDriver, error)
- func (ca *CsvApi) SetReader(r io.Reader)
- func (ca *CsvApi) SetRowDriverToRecord(rd RowDriver, r *Record) error
- func (ca *CsvApi) SetWriter(w io.Writer)
- type DatabaseSchema
- type DatabaseTypeUnmarshaler
- type DefaultConstraintDefinition
- type DiffNode
- type Driver
- func (d *Driver) DecodeValueByColumnIdx(idx int, src []byte) (any, error)
- func (d *Driver) DecodeValueByColumnName(name string, src []byte) (any, error)
- func (d *Driver) DecodeValueByTypeName(name string, src []byte) (any, error)
- func (d *Driver) DecodeValueByTypeOid(oid uint32, src []byte) (any, error)
- func (d *Driver) EncodeValueByColumnIdx(idx int, src any, buf []byte) ([]byte, error)
- func (d *Driver) EncodeValueByColumnName(name string, src any, buf []byte) ([]byte, error)
- func (d *Driver) EncodeValueByTypeName(name string, src any, buf []byte) ([]byte, error)
- func (d *Driver) EncodeValueByTypeOid(oid uint32, src any, buf []byte) ([]byte, error)
- func (d *Driver) GetColumnByName(name string) (int, *Column, bool)
- func (d *Driver) GetTypeMap() *pgtype.Map
- func (d *Driver) ScanValueByColumnIdx(idx int, src []byte, dest any) error
- func (d *Driver) ScanValueByColumnName(name string, src []byte, dest any) error
- func (d *Driver) ScanValueByTypeName(name string, src []byte, dest any) error
- func (d *Driver) ScanValueByTypeOid(oid uint32, src []byte, dest any) error
- type DriverParams
- type DynamicModeProperties
- type DynamicParamValue
- type DynamicParameter
- func (dp *DynamicParameter) GetDefinition() *ParameterDefinition
- func (dp *DynamicParameter) Init(columnParameters map[string]*StaticParameter, dynamicValue *DynamicParamValue) (warnings ValidationWarnings, err error)
- func (dp *DynamicParameter) IsDynamic() bool
- func (dp *DynamicParameter) IsEmpty() (bool, error)
- func (dp *DynamicParameter) RawValue() (ParamsValue, error)
- func (dp *DynamicParameter) Scan(dest any) error
- func (dp *DynamicParameter) SetRecord(r *Record)
- func (dp *DynamicParameter) Value() (value any, err error)
- type DynamicParameterContext
- func (dpc *DynamicParameterContext) DecodeValue(v any) (any, error)
- func (dpc *DynamicParameterContext) DecodeValueByColumn(name string, v any) (any, error)
- func (dpc *DynamicParameterContext) DecodeValueByType(name string, v any) (any, error)
- func (dpc *DynamicParameterContext) EncodeValue(v any) (any, error)
- func (dpc *DynamicParameterContext) EncodeValueByColumn(name string, v any) (any, error)
- func (dpc *DynamicParameterContext) EncodeValueByType(name string, v any) (any, error)
- func (dpc *DynamicParameterContext) GetColumnRawValue(name string) (any, error)
- func (dpc *DynamicParameterContext) GetColumnType() string
- func (dpc *DynamicParameterContext) GetColumnValue(name string) (any, error)
- func (dpc *DynamicParameterContext) GetRawValue() (any, error)
- func (dpc *DynamicParameterContext) GetValue() (any, error)
- type DynamicParameters
- type Exclusion
- type ForeignKey
- type InteractionApi
- type JsonApi
- func (j *JsonApi) Clean()
- func (j *JsonApi) Decode(ctx context.Context) (RowDriver, error)
- func (j *JsonApi) Encode(ctx context.Context, row RowDriver) (err error)
- func (j *JsonApi) GetRowDriverFromRecord(r *Record) (RowDriver, error)
- func (j *JsonApi) SetReader(r io.Reader)
- func (j *JsonApi) SetRowDriverToRecord(rd RowDriver, r *Record) error
- func (j *JsonApi) SetWriter(w io.Writer)
- type JsonRecordWithAttrNames
- func (rr *JsonRecordWithAttrNames) Clean()
- func (rr *JsonRecordWithAttrNames) Decode(data []byte) error
- func (rr *JsonRecordWithAttrNames) Encode() ([]byte, error)
- func (rr *JsonRecordWithAttrNames) GetColumn(idx int) (*RawValue, error)
- func (rr *JsonRecordWithAttrNames) Length() int
- func (rr *JsonRecordWithAttrNames) MarshalJSON() ([]byte, error)
- func (rr *JsonRecordWithAttrNames) SetColumn(idx int, v *RawValue) error
- func (rr *JsonRecordWithAttrNames) UnmarshalJSON(data []byte) error
- type JsonRecordWithAttrNamesBinary
- func (rr *JsonRecordWithAttrNamesBinary) Clean()
- func (rr *JsonRecordWithAttrNamesBinary) Decode(data []byte) error
- func (rr *JsonRecordWithAttrNamesBinary) Encode() ([]byte, error)
- func (rr *JsonRecordWithAttrNamesBinary) GetColumn(idx int) (*RawValue, error)
- func (rr *JsonRecordWithAttrNamesBinary) Length() int
- func (rr *JsonRecordWithAttrNamesBinary) MarshalJSON() ([]byte, error)
- func (rr *JsonRecordWithAttrNamesBinary) SetColumn(idx int, v *RawValue) error
- func (rr *JsonRecordWithAttrNamesBinary) UnmarshalJSON(data []byte) error
- type LinkedTable
- type Meta
- type NewRowDriverFunc
- type NewTransformerFunc
- type NullType
- type Oid
- type ParameterDefinition
- func (p *ParameterDefinition) SetAllowedValues(v ...ParamsValue) *ParameterDefinition
- func (p *ParameterDefinition) SetCastDbType(v string) *ParameterDefinition
- func (p *ParameterDefinition) SetDefaultValue(v ParamsValue) *ParameterDefinition
- func (p *ParameterDefinition) SetDynamicMode(v *DynamicModeProperties) *ParameterDefinition
- func (p *ParameterDefinition) SetGetFromGlobalEnvVariable(v string) *ParameterDefinition
- func (p *ParameterDefinition) SetIsColumn(columnProperties *ColumnProperties) *ParameterDefinition
- func (p *ParameterDefinition) SetIsColumnContainer(v bool) *ParameterDefinition
- func (p *ParameterDefinition) SetLinkParameter(name string) *ParameterDefinition
- func (p *ParameterDefinition) SetRawValueValidator(validator RawValueValidator) *ParameterDefinition
- func (p *ParameterDefinition) SetRequired(v bool) *ParameterDefinition
- func (p *ParameterDefinition) SetSupportTemplate(v bool) *ParameterDefinition
- func (p *ParameterDefinition) SetUnmarshaler(unmarshaler Unmarshaller) *ParameterDefinition
- type ParameterValuer
- type Parameterizer
- type Parameters
- type ParamsValue
- type PrimaryKey
- type RawRecord
- type RawRecordAttrs
- type RawRecordAttrsText
- type RawRecordCsv
- type RawRecordStr
- type RawRecordText
- type RawValue
- type RawValueStr
- type RawValueValidator
- type Record
- func (r *Record) Encode() (RowDriver, error)
- func (r *Record) GetColumnValueByIdx(idx int) (*Value, error)
- func (r *Record) GetColumnValueByName(name string) (*Value, error)
- func (r *Record) GetRawColumnValueByIdx(idx int) (*RawValue, error)
- func (r *Record) GetRawColumnValueByName(name string) (*RawValue, error)
- func (r *Record) GetTuple() (Tuple, error)
- func (r *Record) ScanColumnValueByIdx(idx int, v any) (bool, error)
- func (r *Record) ScanColumnValueByName(name string, v any) (bool, error)
- func (r *Record) SetColumnValueByIdx(idx int, v any) error
- func (r *Record) SetColumnValueByName(name string, v any) error
- func (r *Record) SetRawColumnValueByIdx(idx int, value *RawValue) error
- func (r *Record) SetRawColumnValueByName(name string, value *RawValue) error
- func (r *Record) SetRow(row RowDriver)
- type RecordContext
- func (rc *RecordContext) Clean()
- func (rc *RecordContext) DecodeValueByColumn(name string, v any) (any, error)
- func (rc *RecordContext) DecodeValueByType(name string, v any) (any, error)
- func (rc *RecordContext) EncodeValueByColumn(name string, v any) (any, error)
- func (rc *RecordContext) EncodeValueByType(name string, v any) (any, error)
- func (rc *RecordContext) GetChangedColumns() map[string]struct{}
- func (rc *RecordContext) GetColumnRawValue(name string) (any, error)
- func (rc *RecordContext) GetColumnType(name string) (string, error)
- func (rc *RecordContext) GetColumnValue(name string) (any, error)
- func (rc *RecordContext) SetColumnRawValue(name string, v any) (bool, error)
- func (rc *RecordContext) SetColumnValue(name string, v any) (bool, error)
- func (rc *RecordContext) SetRecord(r *Record)
- type Reference
- type RowDriver
- type StaticParameter
- func (sp *StaticParameter) GetDefinition() *ParameterDefinition
- func (sp *StaticParameter) Init(columnParams map[string]*StaticParameter, rawValue ParamsValue) (ValidationWarnings, error)
- func (sp *StaticParameter) IsDynamic() bool
- func (sp *StaticParameter) IsEmpty() (bool, error)
- func (sp *StaticParameter) RawValue() (ParamsValue, error)
- func (sp *StaticParameter) Scan(dest any) error
- func (sp *StaticParameter) Value() (any, error)
- type StaticParameterContext
- func (spc *StaticParameterContext) DecodeValue(v any) (any, error)
- func (spc *StaticParameterContext) DecodeValueByColumn(name string, v any) (any, error)
- func (spc *StaticParameterContext) DecodeValueByType(name string, v any) (any, error)
- func (spc *StaticParameterContext) EncodeValue(v any) (any, error)
- func (spc *StaticParameterContext) EncodeValueByColumn(name string, v any) (any, error)
- func (spc *StaticParameterContext) EncodeValueByType(name string, v any) (any, error)
- func (spc *StaticParameterContext) GetColumnType(name string) (string, error)
- type StaticParameters
- type Table
- type TestRowDriver
- type TextApi
- func (ta *TextApi) Clean()
- func (ta *TextApi) Decode(ctx context.Context) (RowDriver, error)
- func (ta *TextApi) Encode(ctx context.Context, row RowDriver) (err error)
- func (ta *TextApi) GetRowDriverFromRecord(r *Record) (RowDriver, error)
- func (ta *TextApi) SetReader(r io.Reader)
- func (ta *TextApi) SetRowDriverToRecord(rd RowDriver, r *Record) error
- func (ta *TextApi) SetWriter(w io.Writer)
- type Transformer
- type TransformerDefinition
- func (d *TransformerDefinition) AddParameter(v *ParameterDefinition) *TransformerDefinition
- func (d *TransformerDefinition) SetDescription(v string) *TransformerDefinition
- func (d *TransformerDefinition) SetExpectedExitCode(v int) *TransformerDefinition
- func (d *TransformerDefinition) SetMode(v *DriverParams) *TransformerDefinition
- func (d *TransformerDefinition) SetValidate(v bool) *TransformerDefinition
- type TriggerConstraint
- type Tuple
- type Type
- type TypeCastDefinition
- type TypeCastFunc
- type TypeCaster
- type Unique
- type Unmarshaller
- type ValidationWarning
- func (re *ValidationWarning) AddMeta(key string, value any) *ValidationWarning
- func (re *ValidationWarning) MakeHash()
- func (re *ValidationWarning) SetMsg(msg string) *ValidationWarning
- func (re *ValidationWarning) SetMsgf(msg string, args ...any) *ValidationWarning
- func (re *ValidationWarning) SetSeverity(severity string) *ValidationWarning
- type ValidationWarnings
- type Value
- type WhenCond
Constants ¶
const ( FkConstraintType = "ForeignKey" CheckConstraintType = "Check" NotNullConstraintType = "NotNull" PkConstraintType = "PrimaryKey" PkConstraintReferencesType = "PrimaryKeyReferences" UniqueConstraintType = "Unique" LengthConstraintType = "Length" ExclusionConstraintType = "Exclusion" TriggerConstraintType = "TriggerConstraint" )
const ( CsvAttributesDirectNumeratingFormatName = "direct" CsvAttributesConfigNumeratingFormatName = "config" )
const ( TableMovedToAnotherSchemaDiffEvent = "TableMovedToAnotherSchema" TableRenamedDiffEvent = "TableRenamed" TableCreatedDiffEvent = "TableCreated" ColumnCreatedDiffEvent = "ColumnCreated" ColumnRenamedDiffEvent = "ColumnRenamed" ColumnTypeChangedDiffEvent = "ColumnTypeChanged" )
const ( JsonModeName = "json" CsvModeName = "csv" TextModeName = "text" )
const ( JsonAttributesIndexesFormatName = "indexes" JsonAttributesNamesFormatName = "names" JsonBytesDataFormatName = "bytes" JsonTextDataFormatName = "text" )
const ( MPassword string = "password" MName string = "name" MAddress string = "addr" MEmail string = "email" MMobile string = "mobile" MTelephone string = "tel" MID string = "id" MCreditCard string = "credit_card" MURL string = "url" MDefault string = "default" )
const ( SecUnixUnixName = "sec" MilliUnixUnixName = "milli" MicroUnixUnixName = "micro" NanoUnixUnixName = "nano" )
const ( ErrorValidationSeverity = "error" WarningValidationSeverity = "warning" InfoValidationSeverity = "info" DebugValidationSeverity = "debug" )
const WithoutMaxLength = -1
Variables ¶
var ( UnixNanoToDate = unixLikeToTimeLikeFuncMaker("date", NanoUnixUnixName) UnixMicroToDate = unixLikeToTimeLikeFuncMaker("date", MicroUnixUnixName) UnixMilliToDate = unixLikeToTimeLikeFuncMaker("date", MilliUnixUnixName) UnixSecToDate = unixLikeToTimeLikeFuncMaker("date", SecUnixUnixName) UnixNanoToTimestamp = unixLikeToTimeLikeFuncMaker("timestamp", NanoUnixUnixName) UnixMicroToTimestamp = unixLikeToTimeLikeFuncMaker("timestamp", MicroUnixUnixName) UnixMilliToTimestamp = unixLikeToTimeLikeFuncMaker("timestamp", MilliUnixUnixName) UnixSecToTimestamp = unixLikeToTimeLikeFuncMaker("timestamp", SecUnixUnixName) UnixNanoToTimestampTz = unixLikeToTimeLikeFuncMaker("timestamptz", NanoUnixUnixName) UnixMicroToTimestampTz = unixLikeToTimeLikeFuncMaker("timestamptz", MicroUnixUnixName) UnixMilliToTimestampTz = unixLikeToTimeLikeFuncMaker("timestamptz", MilliUnixUnixName) UnixSecToTimestampTz = unixLikeToTimeLikeFuncMaker("timestamptz", SecUnixUnixName) DateToUnixNano = timeLikeToUnixLikeFuncMaker("date", NanoUnixUnixName) DateToUnixMicro = timeLikeToUnixLikeFuncMaker("date", MicroUnixUnixName) DateToUnixMilli = timeLikeToUnixLikeFuncMaker("date", MilliUnixUnixName) DateToUnixSec = timeLikeToUnixLikeFuncMaker("date", SecUnixUnixName) TimestampToUnixNano = timeLikeToUnixLikeFuncMaker("timestamp", NanoUnixUnixName) TimestampToUnixMicro = timeLikeToUnixLikeFuncMaker("timestamp", MicroUnixUnixName) TimestampToUnixMilli = timeLikeToUnixLikeFuncMaker("timestamp", MilliUnixUnixName) TimestampToUnixSec = timeLikeToUnixLikeFuncMaker("timestamp", SecUnixUnixName) TimestampTzToUnixNano = timeLikeToUnixLikeFuncMaker("timestamptz", NanoUnixUnixName) TimestampTzToUnixMicro = timeLikeToUnixLikeFuncMaker("timestamptz", MicroUnixUnixName) TimestampTzToUnixMilli = timeLikeToUnixLikeFuncMaker("timestamptz", MilliUnixUnixName) TimestampTzToUnixSec = timeLikeToUnixLikeFuncMaker("timestamptz", SecUnixUnixName) )
var CastFunctionsMap = map[string]*TypeCastDefinition{ "UnixNanoToDate": { Cast: UnixNanoToDate, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"date"}, }, "UnixMicroToDate": { Cast: UnixMicroToDate, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"date"}, }, "UnixMilliToDate": { Cast: UnixMilliToDate, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"date"}, }, "UnixSecToDate": { Cast: UnixSecToDate, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"date"}, }, "UnixNanoToTimestamp": { Cast: UnixNanoToTimestamp, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"timestamp"}, }, "UnixMicroToTimestamp": { Cast: UnixMicroToTimestamp, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"timestamp"}, }, "UnixMilliToTimestamp": { Cast: UnixMilliToTimestamp, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"timestamp"}, }, "UnixSecToTimestamp": { Cast: UnixSecToTimestamp, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"timestamp"}, }, "UnixNanoToTimestampTz": { Cast: UnixNanoToTimestampTz, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"timestamptz"}, }, "UnixMicroToTimestampTz": { Cast: UnixMicroToTimestampTz, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"timestamptz"}, }, "UnixMilliToTimestampTz": { Cast: UnixMilliToTimestampTz, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"timestamptz"}, }, "UnixSecToTimestampTz": { Cast: UnixSecToTimestampTz, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"timestamptz"}, }, "DateToUnixNano": { Cast: DateToUnixNano, InputTypes: []string{"date"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "DateToUnixMicro": { Cast: DateToUnixMicro, InputTypes: []string{"date"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "DateToUnixMilli": { Cast: DateToUnixMilli, InputTypes: []string{"date"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "DateToUnixSec": { Cast: DateToUnixSec, InputTypes: []string{"date"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "TimestampToUnixNano": { Cast: TimestampToUnixNano, InputTypes: []string{"timestamp"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "TimestampToUnixMicro": { Cast: TimestampToUnixMicro, InputTypes: []string{"timestamp"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "TimestampToUnixMilli": { Cast: TimestampToUnixMilli, InputTypes: []string{"timestamp"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "TimestampToUnixSec": { Cast: TimestampToUnixSec, InputTypes: []string{"timestamp"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "TimestampTzToUnixNano": { Cast: TimestampTzToUnixNano, InputTypes: []string{"date"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "TimestampTzToUnixMicro": { Cast: TimestampTzToUnixMicro, InputTypes: []string{"timestamptz"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "TimestampTzToUnixMilli": { Cast: TimestampTzToUnixMilli, InputTypes: []string{"timestamptz"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "TimestampTzToUnixSec": { Cast: TimestampTzToUnixSec, InputTypes: []string{"timestamptz"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, "FloatToInt": { Cast: CastFloatToInt, InputTypes: []string{"numeric", "float4", "float8"}, OutputTypes: []string{"int2", "int4", "int8", "numeric"}, }, "IntToFloat": { Cast: CastIntToFloat, InputTypes: []string{"int2", "int4", "int8", "numeric"}, OutputTypes: []string{"numeric", "float4", "float8"}, }, "IntToBool": { Cast: IntToBool, InputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, OutputTypes: []string{"bool"}, }, "BoolToInt": { Cast: BoolToInt, InputTypes: []string{"bool"}, OutputTypes: []string{"int2", "int4", "int8", "numeric", "float4", "float8"}, }, }
var DefaultRowDriverParams = DriverParams{ Name: JsonModeName, JsonDataFormat: JsonBytesDataFormatName, JsonAttributesFormat: JsonAttributesIndexesFormatName, CsvAttributesFormat: CsvAttributesDirectNumeratingFormatName, }
var DiffEventMsgs = map[string]string{ TableMovedToAnotherSchemaDiffEvent: "Table moved to another schema", TableRenamedDiffEvent: "Table renamed", TableCreatedDiffEvent: "Table created", ColumnCreatedDiffEvent: "Column created", ColumnRenamedDiffEvent: "Column renamed", ColumnTypeChangedDiffEvent: "Column type changed", }
var (
KindOfType = map[rune]string{
'b': "Base",
'c': "Composite",
'd': "Domain",
'e': "Enum",
'p': "PreSudo",
'r': "Range",
'm': "Multirange",
}
)
Functions ¶
func AreTypesHaveEqualOrHaveEqualBaseTypes ¶ added in v0.2.0
func CastFloatToInt ¶ added in v0.2.0
func CastIntToFloat ¶ added in v0.2.0
func DefaultDatabaseTypeUnmarshaler ¶ added in v0.2.0
func DefaultDatabaseTypeUnmarshaler(driver *Driver, typeName string, v ParamsValue) (any, error)
func GetCanonicalTypeName ¶ added in v0.2.0
func GetDriverAndRecord ¶ added in v0.2.0
GetDriverAndRecord - return adhoc table for testing TODO: You should generate table definition dynamically using faker as well as table tuples
func IsTypeAllowed ¶ added in v0.2.0
func IsTypeAllowedWithTypeMap ¶ added in v0.2.0
func IsTypeCustom ¶ added in v0.2.0
func NewDriver ¶
func NewDriver(table *Table, customTypes []*Type) (*Driver, ValidationWarnings, error)
func NewTypeCaster ¶ added in v0.2.0
func NewTypeCaster(driver *Driver, inputType, outputType, castFunction string) (*TypeCaster, ValidationWarnings, error)
func NewWhenCond ¶ added in v0.2.1
NewWhenCond - creates a new WhenCond object. It compiles the when condition and returns the compiled program and the record context with the functions for the columns. The functions represent the column names and return the column values. If the when condition is empty, the WhenCond object will always return true.
func NoiseDateV2 ¶ added in v0.2.0
func NoiseFloat ¶ added in v0.2.0
func PrintValidationWarnings ¶ added in v0.2.1
func PrintValidationWarnings(warns ValidationWarnings, resolvedWarnings []string, printAll bool) error
func RandomBool ¶ added in v0.2.0
func RandomFloat ¶ added in v0.2.0
func RandomString ¶ added in v0.2.0
func ScanPointer ¶ added in v0.2.0
func TruncateDate ¶ added in v0.2.0
TruncateDate - truncate date till the provided part of date
Types ¶
type Check ¶
type Check DefaultConstraintDefinition
func (*Check) IsAffected ¶
func (c *Check) IsAffected(column *Column, columnProperties *ColumnProperties) (w ValidationWarnings)
type Column ¶
type Column struct { Idx int `json:"idx"` Name string `json:"name"` TypeName string `json:"type_name"` CanonicalTypeName string `json:"canonical_type_name"` TypeOid Oid `json:"type_oid"` Num AttNum `json:"num"` NotNull bool `json:"not_null"` // Length - length of the attribute Length int `json:"length"` TypeLength int `json:"type_length"` IsGenerated bool `json:"is_generated"` // OverriddenTypeName - replacement of original type. For instance override TEXT to INT2 OverriddenTypeName string `json:"overridden_type_name"` OverriddenTypeOid Oid `json:"overridden_type_oid"` OverriddenTypeSize int `json:"overridden_type_size"` }
func (*Column) GetColumnSize ¶ added in v0.2.0
func (*Column) GetTypeOid ¶ added in v0.2.0
type ColumnProperties ¶
type ColumnProperties struct { // Nullable - shows that transformer can produce NULL value for the column. Togather with Affected shows that // this parameter may generate null values and write it in this column. It only plays with Affected Nullable bool `mapstructure:"nullable" json:"nullable,omitempty"` // Unique - shows that transformer guarantee that every transformer call the value will be unique. It only plays // with Affected Unique bool `mapstructure:"unique" json:"unique,omitempty"` // Unique - defines max length of the value. It only plays with Affected. Togather with Affected shows // that values will not exceed the length of the column. It only plays with Affected MaxLength int `mapstructure:"max_length" json:"max_length,omitempty"` // Affected - shows assigned column name will be affected after the transformation Affected bool `mapstructure:"affected" json:"affected,omitempty"` // AllowedTypes - defines all the allowed column types in textual format. If not assigned (nil) then any // of the types is valid // TODO: AllowedTypes has a problem if we set int and our column is int2, then it cause an error though // it is workable case. Decide how to define subtype or type "aliases" references. // Also it has problem with custom type naming because it has schema name and type name. It might be better // to describe types with {{ schemaName }}.{{ typeName }}, but then we have to implement types classes // (such as textual, digits, etc.) AllowedTypes []string `mapstructure:"allowed_types" json:"allowed_types,omitempty"` // SkipOriginalData - Is transformer require original data or not SkipOriginalData bool `mapstructure:"skip_original_data" json:"skip_original_data,omitempty"` // TODO: Implement SkipOnNull // SkipOnNull - transformation for column with NULL is not expected SkipOnNull bool `mapstructure:"skip_on_null" json:"skip_on_null"` }
ColumnProperties - column-like parameter properties that would help to understand the affection on the consistency
func NewColumnProperties ¶
func NewColumnProperties() *ColumnProperties
func (*ColumnProperties) SetAffected ¶
func (cp *ColumnProperties) SetAffected(v bool) *ColumnProperties
func (*ColumnProperties) SetAllowedColumnTypes ¶
func (cp *ColumnProperties) SetAllowedColumnTypes(v ...string) *ColumnProperties
func (*ColumnProperties) SetMaxLength ¶
func (cp *ColumnProperties) SetMaxLength(v int) *ColumnProperties
func (*ColumnProperties) SetNullable ¶
func (cp *ColumnProperties) SetNullable(v bool) *ColumnProperties
func (*ColumnProperties) SetSkipOnNull ¶
func (cp *ColumnProperties) SetSkipOnNull(v bool) *ColumnProperties
func (*ColumnProperties) SetSkipOriginalData ¶
func (cp *ColumnProperties) SetSkipOriginalData(v bool) *ColumnProperties
func (*ColumnProperties) SetUnique ¶
func (cp *ColumnProperties) SetUnique(v bool) *ColumnProperties
type Constraint ¶
type Constraint interface { IsAffected(column *Column, columnProperties *ColumnProperties) (w ValidationWarnings) Type() string }
type CsvApi ¶
type CsvApi struct {
// contains filtered or unexported fields
}
func NewCsvApi ¶
func NewCsvApi(transferringColumns []*Column, affectedColumns []*Column, driver *Driver, params *DriverParams) *CsvApi
func (*CsvApi) GetRowDriverFromRecord ¶
func (*CsvApi) SetRowDriverToRecord ¶
type DatabaseSchema ¶ added in v0.1.7
type DatabaseSchema []*Table
func (DatabaseSchema) Diff ¶ added in v0.1.7
func (ds DatabaseSchema) Diff(current DatabaseSchema) (res []*DiffNode)
type DatabaseTypeUnmarshaler ¶ added in v0.2.0
type DatabaseTypeUnmarshaler func(driver *Driver, typeName string, v ParamsValue) (any, error)
type DefaultConstraintDefinition ¶
type DefaultConstraintDefinition struct { // Schema - constraint schema name Schema string `json:"schema"` // Name - constraint name Name string `json:"name"` // Oid - Constraint oid in pg_constraint Oid Oid `json:"oid"` // Columns - columns involved into constraint Columns []AttNum `json:"columns,omitempty"` // Definition - real textual constraint definition Definition string `json:"definition,omitempty"` }
type Driver ¶
type Driver struct { Table *Table TypeMapPool []*pgtype.Map // ColumnMap - map column name to Column object ColumnMap map[string]*Column // AttrIdxMap - the number of attribute in tuple AttrIdxMap map[string]int // CustomTypes - list of custom types used in tables CustomTypes []*Type // contains filtered or unexported fields }
Driver - allows you to perform decoding operations from []bytes to go types and go types to bytes encoding operation TODO: Rename it to table Driver
func (*Driver) DecodeValueByColumnIdx ¶
func (*Driver) DecodeValueByColumnName ¶
func (*Driver) DecodeValueByTypeName ¶
func (*Driver) DecodeValueByTypeOid ¶
func (*Driver) EncodeValueByColumnIdx ¶
func (*Driver) EncodeValueByColumnName ¶
func (*Driver) EncodeValueByTypeName ¶
func (*Driver) EncodeValueByTypeOid ¶
func (*Driver) GetTypeMap ¶ added in v0.2.0
func (*Driver) ScanValueByColumnIdx ¶
func (*Driver) ScanValueByColumnName ¶
func (*Driver) ScanValueByTypeName ¶
type DriverParams ¶ added in v0.1.7
type DriverParams struct { Name string `json:"name"` JsonDataFormat string `json:"json_data_format,omitempty"` JsonAttributesFormat string `json:"json_attributes_format,omitempty"` CsvAttributesFormat string `json:"csv_attributes_format,omitempty"` }
func (*DriverParams) Validate ¶ added in v0.1.7
func (dp *DriverParams) Validate() error
Validate - validate driver params and set default values if needed
type DynamicModeProperties ¶ added in v0.2.0
type DynamicModeProperties struct { SupportedTypes []string Unmarshal DatabaseTypeUnmarshaler `json:"-"` }
func NewDynamicModeProperties ¶ added in v0.2.0
func NewDynamicModeProperties() *DynamicModeProperties
func (*DynamicModeProperties) SetCompatibleTypes ¶ added in v0.2.0
func (dmp *DynamicModeProperties) SetCompatibleTypes(compatibleTypes ...string) *DynamicModeProperties
func (*DynamicModeProperties) SetUnmarshaler ¶ added in v0.2.0
func (dmp *DynamicModeProperties) SetUnmarshaler(unmarshaler DatabaseTypeUnmarshaler) *DynamicModeProperties
type DynamicParamValue ¶ added in v0.2.0
type DynamicParamValue struct { Column string `mapstructure:"column" json:"column,omitempty"` CastTo string `mapstructure:"cast_to" json:"cast_to,omitempty"` Template string `mapstructure:"template" json:"template,omitempty"` DefaultValue ParamsValue `mapstructure:"default_value" json:"default_value,omitempty"` }
func (*DynamicParamValue) ParameterValuer ¶ added in v0.2.0
func (dpv *DynamicParamValue) ParameterValuer()
type DynamicParameter ¶ added in v0.2.0
type DynamicParameter struct { // DynamicValue - The dynamic value settings that received from config DynamicValue *DynamicParamValue // contains filtered or unexported fields }
func NewDynamicParameter ¶ added in v0.2.0
func NewDynamicParameter(def *ParameterDefinition, driver *Driver) *DynamicParameter
func (*DynamicParameter) GetDefinition ¶ added in v0.2.0
func (dp *DynamicParameter) GetDefinition() *ParameterDefinition
func (*DynamicParameter) Init ¶ added in v0.2.0
func (dp *DynamicParameter) Init(columnParameters map[string]*StaticParameter, dynamicValue *DynamicParamValue) (warnings ValidationWarnings, err error)
func (*DynamicParameter) IsDynamic ¶ added in v0.2.0
func (dp *DynamicParameter) IsDynamic() bool
func (*DynamicParameter) IsEmpty ¶ added in v0.2.0
func (dp *DynamicParameter) IsEmpty() (bool, error)
func (*DynamicParameter) RawValue ¶ added in v0.2.0
func (dp *DynamicParameter) RawValue() (ParamsValue, error)
func (*DynamicParameter) Scan ¶ added in v0.2.0
func (dp *DynamicParameter) Scan(dest any) error
func (*DynamicParameter) SetRecord ¶ added in v0.2.0
func (dp *DynamicParameter) SetRecord(r *Record)
func (*DynamicParameter) Value ¶ added in v0.2.0
func (dp *DynamicParameter) Value() (value any, err error)
type DynamicParameterContext ¶ added in v0.2.0
type DynamicParameterContext struct {
// contains filtered or unexported fields
}
func NewDynamicParameterContext ¶ added in v0.2.0
func NewDynamicParameterContext(column *Column) *DynamicParameterContext
func (*DynamicParameterContext) DecodeValue ¶ added in v0.2.0
func (dpc *DynamicParameterContext) DecodeValue(v any) (any, error)
func (*DynamicParameterContext) DecodeValueByColumn ¶ added in v0.2.0
func (dpc *DynamicParameterContext) DecodeValueByColumn(name string, v any) (any, error)
func (*DynamicParameterContext) DecodeValueByType ¶ added in v0.2.0
func (dpc *DynamicParameterContext) DecodeValueByType(name string, v any) (any, error)
func (*DynamicParameterContext) EncodeValue ¶ added in v0.2.0
func (dpc *DynamicParameterContext) EncodeValue(v any) (any, error)
func (*DynamicParameterContext) EncodeValueByColumn ¶ added in v0.2.0
func (dpc *DynamicParameterContext) EncodeValueByColumn(name string, v any) (any, error)
func (*DynamicParameterContext) EncodeValueByType ¶ added in v0.2.0
func (dpc *DynamicParameterContext) EncodeValueByType(name string, v any) (any, error)
func (*DynamicParameterContext) GetColumnRawValue ¶ added in v0.2.0
func (dpc *DynamicParameterContext) GetColumnRawValue(name string) (any, error)
func (*DynamicParameterContext) GetColumnType ¶ added in v0.2.0
func (dpc *DynamicParameterContext) GetColumnType() string
func (*DynamicParameterContext) GetColumnValue ¶ added in v0.2.0
func (dpc *DynamicParameterContext) GetColumnValue(name string) (any, error)
func (*DynamicParameterContext) GetRawValue ¶ added in v0.2.0
func (dpc *DynamicParameterContext) GetRawValue() (any, error)
func (*DynamicParameterContext) GetValue ¶ added in v0.2.0
func (dpc *DynamicParameterContext) GetValue() (any, error)
type DynamicParameters ¶ added in v0.2.0
type DynamicParameters map[string]*DynamicParamValue
type Exclusion ¶
type Exclusion DefaultConstraintDefinition
func NewExclusion ¶
func (*Exclusion) IsAffected ¶
func (e *Exclusion) IsAffected(column *Column, columnProperties *ColumnProperties) (w ValidationWarnings)
type ForeignKey ¶
type ForeignKey struct { DefaultConstraintDefinition // ReferencedTable - table that has primary key definition on that discovering table is referencing ReferencedTable LinkedTable `json:"referencedTable,omitempty"` }
func NewForeignKey ¶
func NewForeignKey(schema, name, definition string, oid Oid, columns []AttNum, referencedTable LinkedTable) *ForeignKey
func (*ForeignKey) IsAffected ¶
func (fk *ForeignKey) IsAffected(column *Column, columnProperties *ColumnProperties) (w ValidationWarnings)
func (*ForeignKey) Type ¶ added in v0.1.7
func (fk *ForeignKey) Type() string
type InteractionApi ¶
type InteractionApi interface { // SetWriter - assign writer SetWriter(w io.Writer) // SetReader - assign reader SetReader(r io.Reader) // GetRowDriverFromRecord - get from toolkit.Record all the required attributes as a toolkit.RowDriver instance GetRowDriverFromRecord(r *Record) (RowDriver, error) // SetRowDriverToRecord - set transformed toolkit.RowDriver to the toolkit.Record SetRowDriverToRecord(rd RowDriver, r *Record) error // Encode - write encoded data with \n symbol in the end into io.Writer Encode(ctx context.Context, row RowDriver) error // Decode - read data with new line from io.Reader and encode to toolkit.RowDriver Decode(ctx context.Context) (RowDriver, error) // Clean - clean cached Record Clean() }
InteractionApi - API for interaction with Cmd transformer. It must implement context cancellation, RW timeouts, encode-decode operations, extracting DTO and assigning received DTO to the toolkit.Record
func NewApi ¶
func NewApi(rowDriverParams *DriverParams, transferringColumns []*Column, affectedColumns []*Column, driver *Driver) (InteractionApi, error)
type JsonApi ¶
type JsonApi struct {
// contains filtered or unexported fields
}
func NewJsonApi ¶
func NewJsonApi( transferringColumns []*Column, affectedColumns []*Column, params *DriverParams, ) (*JsonApi, error)
func (*JsonApi) GetRowDriverFromRecord ¶
func (*JsonApi) SetRowDriverToRecord ¶
type JsonRecordWithAttrNames ¶ added in v0.1.7
type JsonRecordWithAttrNames struct {
// contains filtered or unexported fields
}
func NewJsonRecordWithAttrNamesText ¶ added in v0.1.7
func NewJsonRecordWithAttrNamesText(columns []*Column) *JsonRecordWithAttrNames
func (*JsonRecordWithAttrNames) Clean ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNames) Clean()
func (*JsonRecordWithAttrNames) Decode ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNames) Decode(data []byte) error
func (*JsonRecordWithAttrNames) Encode ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNames) Encode() ([]byte, error)
func (*JsonRecordWithAttrNames) GetColumn ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNames) GetColumn(idx int) (*RawValue, error)
func (*JsonRecordWithAttrNames) Length ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNames) Length() int
func (*JsonRecordWithAttrNames) MarshalJSON ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNames) MarshalJSON() ([]byte, error)
func (*JsonRecordWithAttrNames) SetColumn ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNames) SetColumn(idx int, v *RawValue) error
func (*JsonRecordWithAttrNames) UnmarshalJSON ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNames) UnmarshalJSON(data []byte) error
type JsonRecordWithAttrNamesBinary ¶ added in v0.1.7
type JsonRecordWithAttrNamesBinary struct {
// contains filtered or unexported fields
}
func NewJsonRecordWithAttrNamesBinary ¶ added in v0.1.7
func NewJsonRecordWithAttrNamesBinary(columns []*Column) *JsonRecordWithAttrNamesBinary
func (*JsonRecordWithAttrNamesBinary) Clean ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNamesBinary) Clean()
func (*JsonRecordWithAttrNamesBinary) Decode ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNamesBinary) Decode(data []byte) error
func (*JsonRecordWithAttrNamesBinary) Encode ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNamesBinary) Encode() ([]byte, error)
func (*JsonRecordWithAttrNamesBinary) GetColumn ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNamesBinary) GetColumn(idx int) (*RawValue, error)
func (*JsonRecordWithAttrNamesBinary) Length ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNamesBinary) Length() int
func (*JsonRecordWithAttrNamesBinary) MarshalJSON ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNamesBinary) MarshalJSON() ([]byte, error)
func (*JsonRecordWithAttrNamesBinary) SetColumn ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNamesBinary) SetColumn(idx int, v *RawValue) error
func (*JsonRecordWithAttrNamesBinary) UnmarshalJSON ¶ added in v0.1.7
func (rr *JsonRecordWithAttrNamesBinary) UnmarshalJSON(data []byte) error
type LinkedTable ¶
type LinkedTable struct { // Schema - table schema name Schema string `json:"schema"` // Name - table name Name string `json:"name"` // Oid - table oid Oid Oid `json:"oid"` // Constraint - linked table constraint Constraint Constraint `json:"constraint,omitempty"` }
LinkedTable - table that involved into constraint, required for ForeignKey and PrimaryKeyReferences
type Meta ¶
type Meta struct { Table *Table `json:"table"` Parameters *Parameters `json:"parameters"` Types []*Type `json:"types"` ColumnsTypeOverride map[string]string `json:"columns_type_override"` }
type NewRowDriverFunc ¶
type NewRowDriverFunc func() RowDriver
type NewTransformerFunc ¶
type NewTransformerFunc func(ctx context.Context, driver *Driver, parameters map[string]Parameterizer) ( Transformer, ValidationWarnings, error, )
type ParameterDefinition ¶ added in v0.2.0
type ParameterDefinition struct { // Name - name of the parameter. Must be unique in the whole Transformer parameters slice Name string `mapstructure:"name" json:"name"` // Description - description of the parameter. Should contain the brief info about parameter Description string `mapstructure:"description" json:"description"` // Required - shows that parameter is required, and we expect we have to receive this value from config. // Event when DefaultValue is defined it will case error Required bool `mapstructure:"required" json:"required"` // IsColumn - shows is this parameter column related. If so ColumnProperties must be defined and assigned // otherwise it may cause an unhandled behaviour IsColumn bool `mapstructure:"is_column" json:"is_column"` // IsColumnContainer - describe is parameter container map or list with multiple columns inside. It allows us to IsColumnContainer bool `mapstructure:"is_column_container" json:"is_column_container"` // LinkColumnParameter - link with parameter with provided name. This is required if performing raw value encoding // depends on the provided column type and/or relies on the database Driver LinkColumnParameter string `mapstructure:"link_column_parameter" json:"link_column_parameter,omitempty"` // CastDbType - name of PostgreSQL type that would be used for Decoding raw value to the real go type. Is this // type does not exist will cause an error CastDbType string `mapstructure:"cast_db_type" json:"cast_db_type,omitempty"` // GlobalEnvVariable - the nane of the global environment variable that can be used on empty input GetFromGlobalEnvVariable string `mapstructure:"get_from_global_env_variable" json:"get_from_global_env_variable,omitempty"` // DynamicModeProperties - shows that parameter support dynamic mode and contains allowed types and unmarshaler DynamicModeProperties *DynamicModeProperties // DefaultValue - default value of the parameter DefaultValue ParamsValue `mapstructure:"default_value" json:"default_value,omitempty"` // ColumnProperties - detail info about expected column properties that may help to diagnose the table schema // and perform validation procedure Plays only with IsColumn ColumnProperties *ColumnProperties `mapstructure:"column_properties" json:"column_properties,omitempty"` // SupportTemplate - shows that parameter supports golang template and might be calculated dynamically SupportTemplate bool `mapstructure:"support_template" json:"support_template,omitempty"` // Unmarshaller - unmarshal function for the parameter raw data []byte. Using by default json.Unmarshal function Unmarshaller Unmarshaller `json:"-"` // RawValueValidator - raw value validator function that performs assertion and cause ValidationWarnings if it // has violations RawValueValidator RawValueValidator `json:"-"` // AllowedValues - slice of values which allowed to use AllowedValues []ParamsValue `mapstructure:"allowed_values" json:"allowed_values,omitempty"` }
ParameterDefinition - wide parameter entity definition that contains properties that allows to check schema, find affection, cast variable using some features and so on. It may be defined and assigned ot the TransformerDefinition of the transformer if transformer has any parameters
func MustNewParameterDefinition ¶ added in v0.2.0
func MustNewParameterDefinition(name string, description string) *ParameterDefinition
func NewParameterDefinition ¶ added in v0.2.0
func NewParameterDefinition(name string, description string) (*ParameterDefinition, error)
func (*ParameterDefinition) SetAllowedValues ¶ added in v0.2.0
func (p *ParameterDefinition) SetAllowedValues(v ...ParamsValue) *ParameterDefinition
func (*ParameterDefinition) SetCastDbType ¶ added in v0.2.0
func (p *ParameterDefinition) SetCastDbType(v string) *ParameterDefinition
func (*ParameterDefinition) SetDefaultValue ¶ added in v0.2.0
func (p *ParameterDefinition) SetDefaultValue(v ParamsValue) *ParameterDefinition
func (*ParameterDefinition) SetDynamicMode ¶ added in v0.2.0
func (p *ParameterDefinition) SetDynamicMode(v *DynamicModeProperties) *ParameterDefinition
func (*ParameterDefinition) SetGetFromGlobalEnvVariable ¶ added in v0.2.0
func (p *ParameterDefinition) SetGetFromGlobalEnvVariable(v string) *ParameterDefinition
func (*ParameterDefinition) SetIsColumn ¶ added in v0.2.0
func (p *ParameterDefinition) SetIsColumn(columnProperties *ColumnProperties) *ParameterDefinition
func (*ParameterDefinition) SetIsColumnContainer ¶ added in v0.2.0
func (p *ParameterDefinition) SetIsColumnContainer(v bool) *ParameterDefinition
func (*ParameterDefinition) SetLinkParameter ¶ added in v0.2.0
func (p *ParameterDefinition) SetLinkParameter(name string) *ParameterDefinition
func (*ParameterDefinition) SetRawValueValidator ¶ added in v0.2.0
func (p *ParameterDefinition) SetRawValueValidator(validator RawValueValidator) *ParameterDefinition
func (*ParameterDefinition) SetRequired ¶ added in v0.2.0
func (p *ParameterDefinition) SetRequired(v bool) *ParameterDefinition
func (*ParameterDefinition) SetSupportTemplate ¶ added in v0.2.0
func (p *ParameterDefinition) SetSupportTemplate(v bool) *ParameterDefinition
func (*ParameterDefinition) SetUnmarshaler ¶ added in v0.2.0
func (p *ParameterDefinition) SetUnmarshaler(unmarshaler Unmarshaller) *ParameterDefinition
type ParameterValuer ¶ added in v0.2.0
type ParameterValuer interface {
Value()
}
type Parameterizer ¶ added in v0.2.0
type Parameterizer interface { Value() (value any, err error) RawValue() (rawValue ParamsValue, err error) Scan(dest any) (err error) GetDefinition() *ParameterDefinition IsDynamic() bool IsEmpty() (bool, error) }
type Parameters ¶ added in v0.2.0
type Parameters struct { Static StaticParameters `json:"static,omitempty"` Dynamic DynamicParameters `json:"dynamic,omitempty"` }
type ParamsValue ¶
type ParamsValue []byte
func (*ParamsValue) ParameterValuer ¶ added in v0.2.0
func (pv *ParamsValue) ParameterValuer()
func (*ParamsValue) UnmarshalJSON ¶
func (pv *ParamsValue) UnmarshalJSON(data []byte) error
type PrimaryKey ¶
type PrimaryKey struct { DefaultConstraintDefinition References []*LinkedTable }
func NewPrimaryKey ¶
func NewPrimaryKey(schema, name, definition string, oid Oid, columns []AttNum) *PrimaryKey
func (*PrimaryKey) IsAffected ¶
func (pk *PrimaryKey) IsAffected(column *Column, columnProperties *ColumnProperties) (w ValidationWarnings)
func (*PrimaryKey) Type ¶ added in v0.1.7
func (pk *PrimaryKey) Type() string
type RawRecordAttrs ¶ added in v0.1.7
type RawRecordAttrsText ¶ added in v0.1.7
type RawRecordAttrsText map[string]*RawValueStr
type RawRecordCsv ¶
type RawRecordCsv struct { Data []string // contains filtered or unexported fields }
func NewRawRecordCsv ¶
func NewRawRecordCsv(size int, columnRemap []*Column) *RawRecordCsv
func (*RawRecordCsv) Clean ¶
func (rr *RawRecordCsv) Clean()
func (*RawRecordCsv) Decode ¶
func (rr *RawRecordCsv) Decode(data []byte) (err error)
func (*RawRecordCsv) Encode ¶
func (rr *RawRecordCsv) Encode() ([]byte, error)
func (*RawRecordCsv) Length ¶
func (rr *RawRecordCsv) Length() int
type RawRecordStr ¶
type RawRecordStr map[int]*RawValueStr
RawRecordStr - Record data transfer object for interaction with custom transformer via PIPE
func (*RawRecordStr) Clean ¶
func (rrs *RawRecordStr) Clean()
func (*RawRecordStr) Decode ¶
func (rrs *RawRecordStr) Decode(data []byte) error
func (*RawRecordStr) Encode ¶
func (rrs *RawRecordStr) Encode() ([]byte, error)
func (*RawRecordStr) Length ¶
func (rrs *RawRecordStr) Length() int
type RawRecordText ¶
type RawRecordText []byte
var DefaultNullSeq RawRecordText = []byte("\\N")
func NewRawRecordText ¶
func NewRawRecordText() *RawRecordText
func (*RawRecordText) Clean ¶
func (r *RawRecordText) Clean()
func (*RawRecordText) Decode ¶
func (r *RawRecordText) Decode(data []byte) error
func (*RawRecordText) Encode ¶
func (r *RawRecordText) Encode() ([]byte, error)
func (*RawRecordText) Length ¶
func (r *RawRecordText) Length() int
type RawValue ¶
func NewRawValue ¶
type RawValueStr ¶
func NewRawValueStr ¶
func NewRawValueStr(data []byte, isNull bool) *RawValueStr
type RawValueValidator ¶
type RawValueValidator func(p *ParameterDefinition, v ParamsValue) (ValidationWarnings, error)
type Record ¶
func (*Record) GetColumnValueByName ¶
func (*Record) GetRawColumnValueByIdx ¶
func (*Record) GetRawColumnValueByName ¶
func (*Record) ScanColumnValueByIdx ¶
ScanColumnValueByIdx - scan data from column with name into v and return isNull property and error
func (*Record) ScanColumnValueByName ¶
func (*Record) SetColumnValueByName ¶
SetColumnValueByName - set transformed attribute to the tuple
func (*Record) SetRawColumnValueByIdx ¶
func (*Record) SetRawColumnValueByName ¶
type RecordContext ¶ added in v0.2.0
type RecordContext struct {
// contains filtered or unexported fields
}
func NewRecordContext ¶ added in v0.2.0
func NewRecordContext() *RecordContext
func (*RecordContext) Clean ¶ added in v0.2.0
func (rc *RecordContext) Clean()
func (*RecordContext) DecodeValueByColumn ¶ added in v0.2.0
func (rc *RecordContext) DecodeValueByColumn(name string, v any) (any, error)
DecodeValueByColumn - decode value from string or NullValue to the real type using column type
func (*RecordContext) DecodeValueByType ¶ added in v0.2.0
func (rc *RecordContext) DecodeValueByType(name string, v any) (any, error)
DecodeValueByType - decode value from string or NullValue to the real type using type
func (*RecordContext) EncodeValueByColumn ¶ added in v0.2.0
func (rc *RecordContext) EncodeValueByColumn(name string, v any) (any, error)
EncodeValueByColumn - encode value from real type to the string or NullValue using column type
func (*RecordContext) EncodeValueByType ¶ added in v0.2.0
func (rc *RecordContext) EncodeValueByType(name string, v any) (any, error)
EncodeValueByType - encode value from real type to the string or NullValue using type
func (*RecordContext) GetChangedColumns ¶ added in v0.2.0
func (rc *RecordContext) GetChangedColumns() map[string]struct{}
func (*RecordContext) GetColumnRawValue ¶ added in v0.2.1
func (rc *RecordContext) GetColumnRawValue(name string) (any, error)
func (*RecordContext) GetColumnType ¶ added in v0.2.0
func (rc *RecordContext) GetColumnType(name string) (string, error)
func (*RecordContext) GetColumnValue ¶ added in v0.2.0
func (rc *RecordContext) GetColumnValue(name string) (any, error)
func (*RecordContext) SetColumnRawValue ¶ added in v0.2.1
func (rc *RecordContext) SetColumnRawValue(name string, v any) (bool, error)
func (*RecordContext) SetColumnValue ¶ added in v0.2.0
func (rc *RecordContext) SetColumnValue(name string, v any) (bool, error)
func (*RecordContext) SetRecord ¶ added in v0.2.0
func (rc *RecordContext) SetRecord(r *Record)
type RowDriver ¶
type RowDriver interface { // GetColumn - get raw []byte value by column idx GetColumn(idx int) (*RawValue, error) // SetColumn - set RawValue value by column idx to the current row SetColumn(idx int, v *RawValue) error // Encode - encode the whole row to the []byte representation of RowDriver. It would be CSV // line or JSON object, etc. Encode() ([]byte, error) // Decode - decode []bytes to RowDriver instance Decode([]byte) error // Length - count of attributes in the row Length() int // Clean - clean the state Clean() }
RowDriver - represents methods for interacts with any transferring format It might be COPY, CSV, JSON, etc. See implementation pgcopy.Row RowDriver must keep the current row state
type StaticParameter ¶ added in v0.2.0
type StaticParameter struct { // Column - column of the table that was assigned in the parsing procedure according to provided Column name in // parameter value. In this case value has textual column name Column *Column // contains filtered or unexported fields }
func NewStaticParameter ¶ added in v0.2.0
func NewStaticParameter(def *ParameterDefinition, driver *Driver) *StaticParameter
func (*StaticParameter) GetDefinition ¶ added in v0.2.0
func (sp *StaticParameter) GetDefinition() *ParameterDefinition
func (*StaticParameter) Init ¶ added in v0.2.0
func (sp *StaticParameter) Init(columnParams map[string]*StaticParameter, rawValue ParamsValue) (ValidationWarnings, error)
func (*StaticParameter) IsDynamic ¶ added in v0.2.0
func (sp *StaticParameter) IsDynamic() bool
func (*StaticParameter) IsEmpty ¶ added in v0.2.0
func (sp *StaticParameter) IsEmpty() (bool, error)
func (*StaticParameter) RawValue ¶ added in v0.2.0
func (sp *StaticParameter) RawValue() (ParamsValue, error)
func (*StaticParameter) Scan ¶ added in v0.2.0
func (sp *StaticParameter) Scan(dest any) error
func (*StaticParameter) Value ¶ added in v0.2.0
func (sp *StaticParameter) Value() (any, error)
type StaticParameterContext ¶ added in v0.2.0
type StaticParameterContext struct {
// contains filtered or unexported fields
}
func NewStaticParameterContext ¶ added in v0.2.0
func NewStaticParameterContext(d *Driver, linkedColumnName string) *StaticParameterContext
func (*StaticParameterContext) DecodeValue ¶ added in v0.2.0
func (spc *StaticParameterContext) DecodeValue(v any) (any, error)
func (*StaticParameterContext) DecodeValueByColumn ¶ added in v0.2.0
func (spc *StaticParameterContext) DecodeValueByColumn(name string, v any) (any, error)
func (*StaticParameterContext) DecodeValueByType ¶ added in v0.2.0
func (spc *StaticParameterContext) DecodeValueByType(name string, v any) (any, error)
func (*StaticParameterContext) EncodeValue ¶ added in v0.2.0
func (spc *StaticParameterContext) EncodeValue(v any) (any, error)
func (*StaticParameterContext) EncodeValueByColumn ¶ added in v0.2.0
func (spc *StaticParameterContext) EncodeValueByColumn(name string, v any) (any, error)
func (*StaticParameterContext) EncodeValueByType ¶ added in v0.2.0
func (spc *StaticParameterContext) EncodeValueByType(name string, v any) (any, error)
func (*StaticParameterContext) GetColumnType ¶ added in v0.2.0
func (spc *StaticParameterContext) GetColumnType(name string) (string, error)
type StaticParameters ¶ added in v0.2.0
type StaticParameters map[string]ParamsValue
func (*StaticParameters) MarshalJSON ¶ added in v0.2.0
func (p *StaticParameters) MarshalJSON() ([]byte, error)
type Table ¶
type Table struct { Schema string `json:"schema"` Name string `json:"name"` Oid Oid `json:"oid"` Columns []*Column `json:"columns"` Kind string `json:"kind"` Parent Oid `json:"parent"` Children []Oid `json:"children"` Size int64 `json:"size"` PrimaryKey []string `json:"primary_key"` Constraints []Constraint `json:"-"` }
type TestRowDriver ¶ added in v0.2.1
type TestRowDriver struct {
// contains filtered or unexported fields
}
func (*TestRowDriver) Clean ¶ added in v0.2.1
func (trd *TestRowDriver) Clean()
func (*TestRowDriver) Decode ¶ added in v0.2.1
func (trd *TestRowDriver) Decode([]byte) error
func (*TestRowDriver) Encode ¶ added in v0.2.1
func (trd *TestRowDriver) Encode() ([]byte, error)
func (*TestRowDriver) GetColumn ¶ added in v0.2.1
func (trd *TestRowDriver) GetColumn(idx int) (*RawValue, error)
func (*TestRowDriver) Length ¶ added in v0.2.1
func (trd *TestRowDriver) Length() int
type TextApi ¶
type TextApi struct {
// contains filtered or unexported fields
}
func (*TextApi) GetRowDriverFromRecord ¶
func (*TextApi) SetRowDriverToRecord ¶
type Transformer ¶
type TransformerDefinition ¶ added in v0.2.0
type TransformerDefinition struct { Name string `json:"name"` Description string `json:"description"` Parameters []*ParameterDefinition `json:"parameters"` Validate bool `json:"validate"` ExpectedExitCode int `json:"expected_exit_code"` Driver *DriverParams `json:"driver"` New NewTransformerFunc `json:"-"` }
func NewTransformerDefinition ¶ added in v0.2.0
func NewTransformerDefinition(name string, makeFunc NewTransformerFunc) *TransformerDefinition
func (*TransformerDefinition) AddParameter ¶ added in v0.2.0
func (d *TransformerDefinition) AddParameter(v *ParameterDefinition) *TransformerDefinition
func (*TransformerDefinition) SetDescription ¶ added in v0.2.0
func (d *TransformerDefinition) SetDescription(v string) *TransformerDefinition
func (*TransformerDefinition) SetExpectedExitCode ¶ added in v0.2.0
func (d *TransformerDefinition) SetExpectedExitCode(v int) *TransformerDefinition
func (*TransformerDefinition) SetMode ¶ added in v0.2.0
func (d *TransformerDefinition) SetMode(v *DriverParams) *TransformerDefinition
func (*TransformerDefinition) SetValidate ¶ added in v0.2.0
func (d *TransformerDefinition) SetValidate(v bool) *TransformerDefinition
type TriggerConstraint ¶
type TriggerConstraint DefaultConstraintDefinition
func NewTriggerConstraint ¶
func NewTriggerConstraint(schema, name, definition string, oid Oid, columns []AttNum) *TriggerConstraint
func (*TriggerConstraint) IsAffected ¶
func (tc *TriggerConstraint) IsAffected(column *Column, columnProperties *ColumnProperties) (w ValidationWarnings)
func (*TriggerConstraint) Type ¶ added in v0.1.7
func (tc *TriggerConstraint) Type() string
type Type ¶
type Type struct { // Oid - pg_type.oid Oid Oid `json:"oid,omitempty"` // ChainOids - list of inherited types (oid) till the main base type ChainOids []Oid `json:"chain_oids,omitempty"` // ChainNames - list of inherited types (name) till the main base type ChainNames []string `json:"chain_names,omitempty"` // Schema - type schema name Schema string `json:"schema,omitempty"` // Name - (pg_type.typname) type name Name string `json:"name,omitempty"` // Length - (pg_type.typelen) for a fixed-size type, typlen is the number of bytes in the internal representation of the type. // But for a variable-length type, typlen is negative. -1 indicates a “varlena” type (one that has a length // word), -2 indicates a null-terminated C string. Length int `json:"length,omitempty"` // Kind - (pg_type.typtype) type of type Kind rune `json:"kind,omitempty"` // ComposedRelation - (pg_type.typrelid) if composite type reference to the table that defines the structure ComposedRelation Oid `json:"composed_relation,omitempty"` // ElementType - (pg_type.typelem) references to the item of the array type ElementType Oid `json:"element_type,omitempty"` // ArrayType - (pg_type.typarray) references to the array type ArrayType Oid `json:"array_type,omitempty"` // NotNull - (pg_type.typnotnull) shows is this type nullable. For domains only NotNull bool `json:"not_null,omitempty"` // BaseType - (pg_type.typbasetype) references to the base type BaseType Oid `json:"base_type,omitempty"` //Check - definition of check constraint Check *Check `json:"check,omitempty"` // RootBuiltInTypeOid - defines builtin type oid that might be used for decoding and encoding RootBuiltInTypeOid Oid `json:"root_built_in_type_oid,omitempty"` // RootBuiltInTypeOid - defines builtin type name that might be used for decoding and encoding RootBuiltInTypeName string `json:"root_built_in_type_name,omitempty"` }
Type - describes pg_catalog.pg_type
func GetCustomType ¶ added in v0.2.0
func (*Type) IsAffected ¶
func (t *Type) IsAffected(p *StaticParameter) (w ValidationWarnings)
type TypeCastDefinition ¶ added in v0.2.0
type TypeCastDefinition struct { Cast TypeCastFunc InputTypes []string OutputTypes []string }
func (*TypeCastDefinition) ValidateTypes ¶ added in v0.2.0
func (tcd *TypeCastDefinition) ValidateTypes(inputType, outputType string) bool
type TypeCastFunc ¶ added in v0.2.0
TypeCastFunc the function implements type casting from one to another
type TypeCaster ¶ added in v0.2.0
type TypeCaster struct {
// contains filtered or unexported fields
}
type Unique ¶
type Unique DefaultConstraintDefinition
func (*Unique) IsAffected ¶
func (u *Unique) IsAffected(column *Column, columnProperties *ColumnProperties) (w ValidationWarnings)
type Unmarshaller ¶
type Unmarshaller func(parameter *ParameterDefinition, driver *Driver, src ParamsValue) (any, error)
type ValidationWarning ¶
type ValidationWarning struct { Msg string `json:"msg,omitempty"` Severity string `json:"severity,omitempty"` Meta map[string]any `json:"meta,omitempty"` Hash string `json:"hash"` }
func NewValidationWarning ¶
func NewValidationWarning() *ValidationWarning
func (*ValidationWarning) AddMeta ¶
func (re *ValidationWarning) AddMeta(key string, value any) *ValidationWarning
func (*ValidationWarning) MakeHash ¶
func (re *ValidationWarning) MakeHash()
func (*ValidationWarning) SetMsg ¶
func (re *ValidationWarning) SetMsg(msg string) *ValidationWarning
func (*ValidationWarning) SetMsgf ¶
func (re *ValidationWarning) SetMsgf(msg string, args ...any) *ValidationWarning
func (*ValidationWarning) SetSeverity ¶
func (re *ValidationWarning) SetSeverity(severity string) *ValidationWarning
type ValidationWarnings ¶
type ValidationWarnings []*ValidationWarning
func InitParameters ¶
func InitParameters( driver *Driver, paramDef []*ParameterDefinition, staticValues map[string]ParamsValue, dynamicValues map[string]*DynamicParamValue, ) (map[string]Parameterizer, ValidationWarnings, error)
func (ValidationWarnings) IsFatal ¶
func (re ValidationWarnings) IsFatal() bool
Source Files ¶
- cmd.go
- column.go
- common.go
- constraints.go
- csv_api.go
- database_schema.go
- definition.go
- driver.go
- dynamic_parameter.go
- expr.go
- interaction_api.go
- json_api.go
- json_record_with_attr_names_binary.go
- json_record_with_attr_names_text.go
- meta.go
- parameter_definition.go
- parametrizer.go
- raw_record.go
- raw_record_csv.go
- raw_record_str.go
- raw_record_text.go
- record.go
- row_driver.go
- static_parameter.go
- static_parameter_context.go
- table.go
- template_functions.go
- template_record_context.go
- tesing_helpers.go
- testutils.go
- text_api.go
- transformation_funcs.go
- transformer.go
- type_cast_functions.go
- type_caster_static_funtions.go
- types.go
- utils.go
- validation_warning.go
- values.go