Fix tests
This commit is contained in:
parent
aec6c89568
commit
9cd8d8ff2c
|
@ -553,7 +553,6 @@ func (db *dameng) Version(ctx context.Context, queryer core.Queryer) (*schemas.V
|
|||
func (db *dameng) Features() *DialectFeatures {
|
||||
return &DialectFeatures{
|
||||
AutoincrMode: SequenceAutoincrMode,
|
||||
SupportSequence: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2021 The Xorm Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build dm
|
||||
|
||||
package integrations
|
||||
|
||||
import "xorm.io/xorm/schemas"
|
||||
|
||||
func init() {
|
||||
dbtypes = append(dbtypes, schemas.DAMENG)
|
||||
}
|
|
@ -135,6 +135,8 @@ func TestDump(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
var dbtypes = []schemas.DBType{schemas.SQLITE, schemas.MYSQL, schemas.POSTGRES, schemas.MSSQL}
|
||||
|
||||
func TestDumpTables(t *testing.T) {
|
||||
assert.NoError(t, PrepareEngine())
|
||||
|
||||
|
@ -170,7 +172,7 @@ func TestDumpTables(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.NoError(t, sess.Commit())
|
||||
|
||||
for _, tp := range []schemas.DBType{schemas.SQLITE, schemas.MYSQL, schemas.POSTGRES, schemas.MSSQL} {
|
||||
for _, tp := range dbtypes {
|
||||
name := fmt.Sprintf("dump_%v-table.sql", tp)
|
||||
t.Run(name, func(t *testing.T) {
|
||||
assert.NoError(t, testEngine.(*xorm.Engine).DumpTablesToFile([]*schemas.Table{tb}, name, tp))
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/schemas"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -624,6 +625,11 @@ func TestAnonymousStruct(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInsertMap(t *testing.T) {
|
||||
if testEngine.Dialect().URI().DBType == schemas.DAMENG {
|
||||
t.SkipNow()
|
||||
return
|
||||
}
|
||||
|
||||
type InsertMap struct {
|
||||
Id int64
|
||||
Width uint32
|
||||
|
@ -727,7 +733,7 @@ func TestInsertWhere(t *testing.T) {
|
|||
}
|
||||
|
||||
inserted, err := testEngine.SetExpr("`index`", "coalesce(MAX(`index`),0)+1").
|
||||
Where("repo_id=?", 1).
|
||||
Where("`repo_id`=?", 1).
|
||||
Insert(&i)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, inserted)
|
||||
|
@ -1067,6 +1073,11 @@ func TestInsertDeleted(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInsertMultipleMap(t *testing.T) {
|
||||
if testEngine.Dialect().URI().DBType == schemas.DAMENG {
|
||||
t.SkipNow()
|
||||
return
|
||||
}
|
||||
|
||||
type InsertMultipleMap struct {
|
||||
Id int64
|
||||
Width uint32
|
||||
|
|
|
@ -97,14 +97,24 @@ func (statement *Statement) GenInsertSQL(colNames []string, args []interface{})
|
|||
return "", nil, err
|
||||
}
|
||||
|
||||
if len(exprs) > 0 {
|
||||
if needSeq {
|
||||
if len(args) > 0 {
|
||||
if _, err := buf.WriteString(","); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
}
|
||||
if _, err := buf.WriteString(utils.SeqName(tableName) + ".nextval"); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
}
|
||||
if len(exprs) > 0 {
|
||||
if _, err := buf.WriteString(","); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
if err := exprs.WriteArgs(buf); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := buf.WriteString(" FROM "); err != nil {
|
||||
return "", nil, err
|
||||
|
|
|
@ -658,6 +658,7 @@ func (session *Session) insertMap(columns []string, args []interface{}) (int64,
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
sql = session.engine.dialect.Quoter().Replace(sql)
|
||||
|
||||
if err := session.cacheInsert(tableName); err != nil {
|
||||
return 0, err
|
||||
|
@ -684,6 +685,7 @@ func (session *Session) insertMultipleMap(columns []string, argss [][]interface{
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
sql = session.engine.dialect.Quoter().Replace(sql)
|
||||
|
||||
if err := session.cacheInsert(tableName); err != nil {
|
||||
return 0, err
|
||||
|
|
Loading…
Reference in New Issue