feat: implement MSSQL row transformation and loading functions
This commit is contained in:
34
cmd/go_migrate/transformer.go
Normal file
34
cmd/go_migrate/transformer.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func transformRowsMssql(columns []ColumnType, in <-chan []UnknownRowValues, out chan<- []UnknownRowValues) {
|
||||
for rows := range in {
|
||||
log.Debugf("Chunk received, transforming...")
|
||||
|
||||
for _, rowValues := range rows {
|
||||
for i, col := range columns {
|
||||
value := rowValues[i]
|
||||
if col.SystemType() == "uniqueidentifier" {
|
||||
if b, ok := value.([]byte); ok {
|
||||
rowValues[i] = mssqlUuidToBigEndian(b)
|
||||
}
|
||||
} else if col.SystemType() == "geometry" || col.SystemType() == "geography" {
|
||||
if b, ok := value.([]byte); ok {
|
||||
rowValues[i] = wkbToEwkbWithSrid(b, 4326)
|
||||
}
|
||||
} else if col.SystemType() == "datetime" || col.SystemType() == "datetime2" {
|
||||
if t, ok := value.(time.Time); ok {
|
||||
rowValues[i] = ensureUTC(t)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out <- rows
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user