dbdataset

package
v1.0.178 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinSlice

func JoinSlice(list any) string

func StrNotEmpty

func StrNotEmpty(s string) bool

Types

type DS

type DS interface {
	Open() error
	OpenContext(ctx context.Context) error
	Close()
	Exec() (sql.Result, error)
	ExecContext(ctx context.Context) (sql.Result, error)
	GetSql() (string, error)
	GetParams() []any
	ParamByName(paramName string) *Param
	SetInputParam(paramName string, paramValue any) *DataSet
	SetOutputParam(paramName string, paramType any) *DataSet
	FieldByName(fieldName string) *Field
	Locate(key string, value any) bool
	First()
	Next()
	Eof() bool
	IsEmpty() bool
	IsNotEmpty() bool
	Count() int
	AddSql(sql string) *DataSet
	ToStruct(model any) error
	ToStructJson(model any) ([]byte, error)
}

type DataSet

type DataSet struct {
	Connection      *dbconnbase.Conn
	Transaction     *dbconnbase.Transaction
	Ctx             context.Context
	Sql             stringlist.Strings
	Fields          *Fields
	Params          *Params
	Macros          *Macros
	Rows            []Row
	Index           int
	Recno           int
	IndexFieldNames string
	Silent          bool
	Name            string
	TagColumn       string
}

func NewDataSet

func NewDataSet(db *dbconnbase.Conn, opts ...OptionsDataset) *DataSet

func NewDataSetTx

func NewDataSetTx(tx *dbconnbase.Transaction, opts ...OptionsDataset) *DataSet

func (*DataSet) AddContext

func (ds *DataSet) AddContext(ctx context.Context) *DataSet

func (*DataSet) AddSql

func (ds *DataSet) AddSql(sql string) *DataSet

func (*DataSet) Bof

func (ds *DataSet) Bof() bool

func (*DataSet) ClearParams

func (ds *DataSet) ClearParams()

func (*DataSet) Close

func (ds *DataSet) Close()

func (*DataSet) Count

func (ds *DataSet) Count() int

func (*DataSet) CreateFields

func (ds *DataSet) CreateFields() error

func (*DataSet) Delete

func (ds *DataSet) Delete() (int64, error)

func (*DataSet) DeleteContext

func (ds *DataSet) DeleteContext(ctx context.Context) (int64, error)

func (*DataSet) Eof

func (ds *DataSet) Eof() bool

func (*DataSet) Exec

func (ds *DataSet) Exec() (sql.Result, error)

func (*DataSet) ExecBatch

func (ds *DataSet) ExecBatch(size int) error

func (*DataSet) ExecContext

func (ds *DataSet) ExecContext(context context.Context) (sql.Result, error)

func (*DataSet) FieldByName

func (ds *DataSet) FieldByName(fieldName string) *Field

func (*DataSet) First

func (ds *DataSet) First()

func (*DataSet) Free

func (ds *DataSet) Free()

func (*DataSet) GetAny added in v1.0.171

func (ds *DataSet) GetAny(fieldName string) any

func (*DataSet) GetBool added in v1.0.171

func (ds *DataSet) GetBool(fieldName string) bool

func (*DataSet) GetBoolNil added in v1.0.171

func (ds *DataSet) GetBoolNil(fieldName string) *bool

func (*DataSet) GetByte added in v1.0.171

func (ds *DataSet) GetByte(fieldName string) []byte

func (*DataSet) GetByteNil added in v1.0.171

func (ds *DataSet) GetByteNil(fieldName string) *[]byte

func (*DataSet) GetDateTime added in v1.0.171

func (ds *DataSet) GetDateTime(fieldName string) time.Time

func (*DataSet) GetDateTimeNil added in v1.0.171

func (ds *DataSet) GetDateTimeNil(fieldName string) *time.Time

func (*DataSet) GetFloat added in v1.0.171

func (ds *DataSet) GetFloat(fieldName string) float32

func (*DataSet) GetFloat64 added in v1.0.171

func (ds *DataSet) GetFloat64(fieldName string) float64

func (*DataSet) GetFloat64Nil added in v1.0.171

func (ds *DataSet) GetFloat64Nil(fieldName string) *float64

func (*DataSet) GetFloatNil added in v1.0.171

func (ds *DataSet) GetFloatNil(fieldName string) *float32

func (*DataSet) GetInt added in v1.0.171

func (ds *DataSet) GetInt(fieldName string) int

func (*DataSet) GetInt8 added in v1.0.171

func (ds *DataSet) GetInt8(fieldName string) int8

func (*DataSet) GetInt8Nil added in v1.0.171

func (ds *DataSet) GetInt8Nil(fieldName string) *int8

func (*DataSet) GetInt16 added in v1.0.171

func (ds *DataSet) GetInt16(fieldName string) int16

func (*DataSet) GetInt16Nil added in v1.0.171

func (ds *DataSet) GetInt16Nil(fieldName string) *int16

func (*DataSet) GetInt32 added in v1.0.171

func (ds *DataSet) GetInt32(fieldName string) int32

func (*DataSet) GetInt32Nil added in v1.0.171

func (ds *DataSet) GetInt32Nil(fieldName string) *int32

func (*DataSet) GetInt64 added in v1.0.171

func (ds *DataSet) GetInt64(fieldName string) int64

func (*DataSet) GetInt64Nil added in v1.0.171

func (ds *DataSet) GetInt64Nil(fieldName string) *int64

func (*DataSet) GetIntNil added in v1.0.171

func (ds *DataSet) GetIntNil(fieldName string) *int

func (*DataSet) GetMacros

func (ds *DataSet) GetMacros() []any

func (*DataSet) GetParams

func (ds *DataSet) GetParams() []any

func (*DataSet) GetParamsBatch

func (ds *DataSet) GetParamsBatch(index int) []any

func (*DataSet) GetSql

func (ds *DataSet) GetSql() (string, error)

func (*DataSet) GetString added in v1.0.171

func (ds *DataSet) GetString(fieldName string) string

func (*DataSet) GetStringNil added in v1.0.171

func (ds *DataSet) GetStringNil(fieldName string) *string

func (*DataSet) GetValue

func (ds *DataSet) GetValue(field *Field, fieldType any) any

func (*DataSet) IsEmpty

func (ds *DataSet) IsEmpty() bool

func (*DataSet) IsNotEmpty

func (ds *DataSet) IsNotEmpty() bool

func (*DataSet) IsNotNull added in v1.0.171

func (ds *DataSet) IsNotNull(fieldName string) bool

func (*DataSet) IsNull added in v1.0.171

func (ds *DataSet) IsNull(fieldName string) bool

func (*DataSet) Last

func (ds *DataSet) Last()

func (*DataSet) Locate

func (ds *DataSet) Locate(key string, value any) bool

func (*DataSet) MacroByName

func (ds *DataSet) MacroByName(macroName string) *Macro

func (*DataSet) Next

func (ds *DataSet) Next()

func (*DataSet) Open

func (ds *DataSet) Open() error

func (*DataSet) OpenContext

func (ds *DataSet) OpenContext(ctx context.Context) error

func (*DataSet) ParamByName

func (ds *DataSet) ParamByName(paramName string) *Param

func (*DataSet) ParseSql

func (ds *DataSet) ParseSql() (sqlparser.Statement, error)

func (*DataSet) Prepare

func (ds *DataSet) Prepare() error

func (*DataSet) Previous

func (ds *DataSet) Previous()

func (*DataSet) PrintParam

func (ds *DataSet) PrintParam()

func (*DataSet) SetInputParam

func (ds *DataSet) SetInputParam(paramName string, paramValue any) *DataSet

func (*DataSet) SetInputParamBlob

func (ds *DataSet) SetInputParamBlob(paramName string, paramValue []byte) *DataSet

func (*DataSet) SetInputParamClob

func (ds *DataSet) SetInputParamClob(paramName string, paramValue string) *DataSet

func (*DataSet) SetMacro

func (ds *DataSet) SetMacro(macroName string, macroValue any) *DataSet

func (*DataSet) SetOutputParam

func (ds *DataSet) SetOutputParam(paramName string, paramValue any) *DataSet

func (*DataSet) SetOutputParamSlice

func (ds *DataSet) SetOutputParamSlice(params ...ParamOut) *DataSet

func (*DataSet) SqlParam

func (ds *DataSet) SqlParam() string

SqlParam retorna o SQL com os parâmetros interpolados em texto.

ATENÇÃO: APENAS PARA DEBUG/LOG. Não escapa aspas em strings — passar o resultado para Exec/Query é vulnerável a SQL injection. Para execução, use sempre GetSql() + GetParams().

func (*DataSet) ToStruct

func (ds *DataSet) ToStruct(model any) error

func (*DataSet) ToStructJson

func (ds *DataSet) ToStructJson(model any) ([]byte, error)

type DataType

type DataType int
const (
	Text     DataType = 0
	Integer  DataType = 1
	Float    DataType = 2
	DateTime DataType = 3
	Boolean  DataType = 4
)

func (*DataType) IntToDataType

func (dt *DataType) IntToDataType(value int) (DataType, error)

type Field

type Field struct {
	Owner      *Fields
	Name       string
	Caption    string
	DataType   *sql.ColumnType
	IDataType  *DataType
	Precision  int64
	Scale      int64
	DataMask   string
	BoolValue  bool
	TrueValue  string
	FalseValue string
	Visible    bool
	AcceptNull bool
	QuoteNull  bool
	OmitNull   bool
	StrNull    string
	Order      int
	Index      int
}

func NewField

func NewField(name string) *Field

func (*Field) AsBool

func (field *Field) AsBool() bool

func (*Field) AsBoolNil

func (field *Field) AsBoolNil() *bool

func (*Field) AsByte

func (field *Field) AsByte() []byte

func (*Field) AsByteNil

func (field *Field) AsByteNil() *[]byte

func (*Field) AsDateTime

func (field *Field) AsDateTime() time.Time

func (*Field) AsDateTimeNil

func (field *Field) AsDateTimeNil() *time.Time

func (*Field) AsFloat

func (field *Field) AsFloat() float32

func (*Field) AsFloat64

func (field *Field) AsFloat64() float64

func (*Field) AsFloat64Nil

func (field *Field) AsFloat64Nil() *float64

func (*Field) AsFloatNil

func (field *Field) AsFloatNil() *float32

func (*Field) AsInt

func (field *Field) AsInt() int

func (*Field) AsInt8

func (field *Field) AsInt8() int8

func (*Field) AsInt8Nil

func (field *Field) AsInt8Nil() *int8

func (*Field) AsInt16

func (field *Field) AsInt16() int16

func (*Field) AsInt16Nil

func (field *Field) AsInt16Nil() *int16

func (*Field) AsInt32

func (field *Field) AsInt32() int32

func (*Field) AsInt32Nil

func (field *Field) AsInt32Nil() *int32

func (*Field) AsInt64

func (field *Field) AsInt64() int64

func (*Field) AsInt64Nil

func (field *Field) AsInt64Nil() *int64

func (*Field) AsIntNil

func (field *Field) AsIntNil() *int

func (*Field) AsString

func (field *Field) AsString() string

func (*Field) AsStringNil

func (field *Field) AsStringNil() *string

func (*Field) AsValue

func (field *Field) AsValue() any

func (*Field) IsNotNull

func (field *Field) IsNotNull() bool

func (*Field) IsNull

func (field *Field) IsNull() bool

type Fields

type Fields struct {
	Owner *DataSet
	List  []*Field
}

func NewFields

func NewFields() *Fields

func (*Fields) Add

func (fd *Fields) Add(fieldName string) *Field

func (*Fields) Clear

func (fd *Fields) Clear() *Fields

func (*Fields) Count

func (fd *Fields) Count() int

func (*Fields) FieldByName

func (fd *Fields) FieldByName(fieldName string) *Field

func (*Fields) FindFieldByName

func (fd *Fields) FindFieldByName(fieldName string) *Field

type Lob

type Lob struct {
	io.Reader
	IsClob bool
}

type Macro

type Macro struct {
	Name  string
	Value *variant.Variant
}

func (*Macro) AsString

func (macro *Macro) AsString() string

func (*Macro) AsValue

func (macro *Macro) AsValue() *variant.Variant

type Macros

type Macros struct {
	Owner *DataSet
	List  []*Macro
}

func NewMacros

func NewMacros() *Macros

func (*Macros) FindMacroByName

func (m *Macros) FindMacroByName(macroName string) *Macro

func (*Macros) MacroByName

func (m *Macros) MacroByName(macroName string) *Macro

func (*Macros) SetMacro

func (m *Macros) SetMacro(macroName string, macroValue any) *Macros

type OptionsDataset

type OptionsDataset func(*DataSet)

func SetName

func SetName(name string) OptionsDataset

type Param

type Param struct {
	Owner     *Params
	Name      string
	Value     *variant.Variant
	ParamType ParamType
	DataType  reflect.Type
	Values    []*variant.Variant
}

func NewParam

func NewParam(paramName string, paramType ParamType) *Param

func (*Param) AsBool

func (param *Param) AsBool() bool

func (*Param) AsDateTime

func (param *Param) AsDateTime() time.Time

func (*Param) AsFloat

func (param *Param) AsFloat() float32

func (*Param) AsFloat64

func (param *Param) AsFloat64() float64

func (*Param) AsInt

func (param *Param) AsInt() int

func (*Param) AsInt8

func (param *Param) AsInt8() int8

func (*Param) AsInt16

func (param *Param) AsInt16() int16

func (*Param) AsInt32

func (param *Param) AsInt32() int32

func (*Param) AsInt64

func (param *Param) AsInt64() int64

func (*Param) AsString

func (param *Param) AsString() string

func (*Param) AsValue

func (param *Param) AsValue() *variant.Variant

type ParamOut

type ParamOut struct {
	Name string
	Dest any
}

type ParamType

type ParamType int
const (
	IN    ParamType = 0
	OUT   ParamType = 1
	INOUT ParamType = 2
)

type Params

type Params struct {
	Owner     *DataSet
	BatchSize int
	List      []*Param
}

func NewParams

func NewParams() *Params

func (*Params) Add

func (p *Params) Add(paramName string) *Param

func (*Params) FindParamByName

func (p *Params) FindParamByName(paramName string) *Param

func (*Params) ParamByName

func (p *Params) ParamByName(paramName string) *Param

func (*Params) PrintParam

func (p *Params) PrintParam()

func (*Params) SetInputParam

func (p *Params) SetInputParam(paramName string, paramValue any) *Params

func (*Params) SetInputParamBlob

func (p *Params) SetInputParamBlob(paramName string, paramValue []byte) *Params

func (*Params) SetInputParamClob

func (p *Params) SetInputParamClob(paramName string, paramValue string) *Params

func (*Params) SetOutputParam

func (p *Params) SetOutputParam(paramName string, paramValue any) *Params

func (*Params) SetOutputParamSlice

func (p *Params) SetOutputParamSlice(params ...ParamOut) *Params

type Row

type Row struct {
	List map[string]*variant.Variant
}

func NewRow

func NewRow() Row

type Value

type Value interface {
	*variant.Variant | variant.Variant
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL