Spanner support enhancements (#101634)
* Adds ability to run integration tests against spanner (by using GRAFANA_TEST_DB=spanner env variable. SPANNER_DB variable then specifies database to use: spannertest, emulator or string like /projects/<project>/instances/<instance>/databases/<db>) * Adds feature to migration dialects to create database from a snapshot, instead of running individual migrations. * Adds first version of Spanner snapshot, prepared from "OSS" migrations. * Uses generated bit-reversed-positive values instead of auto_increment. (As an experiment)
This commit is contained in:
@@ -7,7 +7,6 @@ package xorm
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -346,20 +345,20 @@ func (session *Session) innerInsert(bean any) (int64, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// XXX: hack to handle autoincrement in spanner
|
||||
if len(table.AutoIncrement) > 0 && session.engine.dialect.DBType() == "spanner" {
|
||||
var found bool
|
||||
for _, col := range colNames {
|
||||
if col == table.AutoIncrement {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
colNames = append(colNames, table.AutoIncrement)
|
||||
args = append(args, rand.Int63n(9e15))
|
||||
}
|
||||
}
|
||||
//// XXX: hack to handle autoincrement in spanner
|
||||
//if len(table.AutoIncrement) > 0 && session.engine.dialect.DBType() == "spanner" {
|
||||
// var found bool
|
||||
// for _, col := range colNames {
|
||||
// if col == table.AutoIncrement {
|
||||
// found = true
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// if !found {
|
||||
// colNames = append(colNames, table.AutoIncrement)
|
||||
// args = append(args, rand.Int63n(9e15))
|
||||
// }
|
||||
//}
|
||||
|
||||
exprs := session.statement.exprColumns
|
||||
colPlaces := strings.Repeat("?, ", len(colNames))
|
||||
|
||||
Reference in New Issue
Block a user