column is type-aware; is timezone-conversion aware
also refactored some functions
This commit is contained in:
parent
a637ed1b50
commit
882959ba83
@ -12,10 +12,24 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ColumnType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
UnknownColumnType ColumnType = iota
|
||||||
|
TimestampColumnType = iota
|
||||||
|
DateTimeColumnType = iota
|
||||||
|
)
|
||||||
|
|
||||||
|
type TimezoneConvertion struct {
|
||||||
|
ToTimezone string
|
||||||
|
}
|
||||||
|
|
||||||
type Column struct {
|
type Column struct {
|
||||||
Name string
|
Name string
|
||||||
IsUnsigned bool
|
IsUnsigned bool
|
||||||
Charset string
|
Charset string
|
||||||
|
Type ColumnType
|
||||||
|
timezoneConversion *TimezoneConvertion
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Column) convertArg(arg interface{}) interface{} {
|
func (this *Column) convertArg(arg interface{}) interface{} {
|
||||||
@ -112,20 +126,39 @@ func (this *ColumnList) Names() []string {
|
|||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *ColumnList) GetColumn(columnName string) *Column {
|
||||||
|
if ordinal, ok := this.Ordinals[columnName]; ok {
|
||||||
|
return &this.columns[ordinal]
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (this *ColumnList) SetUnsigned(columnName string) {
|
func (this *ColumnList) SetUnsigned(columnName string) {
|
||||||
this.columns[this.Ordinals[columnName]].IsUnsigned = true
|
this.GetColumn(columnName).IsUnsigned = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ColumnList) IsUnsigned(columnName string) bool {
|
func (this *ColumnList) IsUnsigned(columnName string) bool {
|
||||||
return this.columns[this.Ordinals[columnName]].IsUnsigned
|
return this.GetColumn(columnName).IsUnsigned
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ColumnList) SetCharset(columnName string, charset string) {
|
func (this *ColumnList) SetCharset(columnName string, charset string) {
|
||||||
this.columns[this.Ordinals[columnName]].Charset = charset
|
this.GetColumn(columnName).Charset = charset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ColumnList) GetCharset(columnName string) string {
|
func (this *ColumnList) GetCharset(columnName string) string {
|
||||||
return this.columns[this.Ordinals[columnName]].Charset
|
return this.GetColumn(columnName).Charset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ColumnList) SetColumnType(columnName string, columnType ColumnType) {
|
||||||
|
this.GetColumn(columnName).Type = columnType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ColumnList) GetColumnType(columnName string) ColumnType {
|
||||||
|
return this.GetColumn(columnName).Type
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ColumnList) SetConvertDatetimeToTimestamp(columnName string, toTimezone string) {
|
||||||
|
this.GetColumn(columnName).timezoneConversion = &TimezoneConvertion{ToTimezone: toTimezone}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ColumnList) String() string {
|
func (this *ColumnList) String() string {
|
||||||
|
Loading…
Reference in New Issue
Block a user