From 84d1a51434a876b2a82a5cb1d789979ac18b8867 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 24 Aug 2021 15:33:48 +0800 Subject: [PATCH] Fix test --- dialects/dialect.go | 3 +-- dialects/oracle.go | 10 +++------- dialects/postgres.go | 12 ++++++------ integrations/oracle_test.go | 4 ++-- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/dialects/dialect.go b/dialects/dialect.go index 283da150..dc065d15 100644 --- a/dialects/dialect.go +++ b/dialects/dialect.go @@ -45,8 +45,7 @@ const ( // DialectFeatures represents the features that the dialect supports type DialectFeatures struct { - AutoincrMode int // 0 autoincrement column, 1 sequence - SupportReturnIDWhenInsert bool + AutoincrMode int // 0 autoincrement column, 1 sequence } // Dialect represents a kind of database diff --git a/dialects/oracle.go b/dialects/oracle.go index 6c1bdc79..ce62b51b 100644 --- a/dialects/oracle.go +++ b/dialects/oracle.go @@ -15,6 +15,7 @@ import ( "strings" "xorm.io/xorm/core" + "xorm.io/xorm/internal/utils" "xorm.io/xorm/schemas" ) @@ -542,8 +543,7 @@ func (db *oracle) Version(ctx context.Context, queryer core.Queryer) (*schemas.V func (db *oracle) Features() *DialectFeatures { return &DialectFeatures{ - AutoincrMode: SequenceAutoincrMode, - SupportReturnIDWhenInsert: false, + AutoincrMode: SequenceAutoincrMode, } } @@ -688,10 +688,6 @@ func (db *oracle) IsColumnExist(queryer core.Queryer, ctx context.Context, table return db.HasRecords(queryer, ctx, query, args...) } -func OracleSeqName(tableName string) string { - return "SEQ_" + strings.ToUpper(tableName) -} - func (db *oracle) GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error) { //s := "SELECT column_name,data_default,data_type,data_length,data_precision,data_scale," + // "nullable FROM USER_TAB_COLUMNS WHERE table_name = :1" @@ -755,7 +751,7 @@ func (db *oracle) GetColumns(queryer core.Queryer, ctx context.Context, tableNam if pkName != "" && pkName == col.Name { col.IsPrimaryKey = true - has, err := db.HasRecords(queryer, ctx, "SELECT * FROM USER_SEQUENCES WHERE SEQUENCE_NAME = :1", OracleSeqName(tableName)) + has, err := db.HasRecords(queryer, ctx, "SELECT * FROM USER_SEQUENCES WHERE SEQUENCE_NAME = :1", utils.SeqName(tableName)) if err != nil { return nil, nil, err } diff --git a/dialects/postgres.go b/dialects/postgres.go index e810d803..822d3a70 100644 --- a/dialects/postgres.go +++ b/dialects/postgres.go @@ -876,12 +876,6 @@ func (db *postgres) SetQuotePolicy(quotePolicy QuotePolicy) { } } -func (db *postgres) Features() *DialectFeatures { - return &DialectFeatures{ - AutoincrMode: IncrAutoincrMode, - } -} - func (db *postgres) SQLType(c *schemas.Column) string { var res string switch t := c.SQLType.Name; t { @@ -947,6 +941,12 @@ func (db *postgres) SQLType(c *schemas.Column) string { return res } +func (db *postgres) Features() *DialectFeatures { + return &DialectFeatures{ + AutoincrMode: IncrAutoincrMode, + } +} + func (db *postgres) ColumnTypeKind(t string) int { switch strings.ToUpper(t) { case "DATETIME", "TIMESTAMP": diff --git a/integrations/oracle_test.go b/integrations/oracle_test.go index 56cd3b69..e8ace90c 100644 --- a/integrations/oracle_test.go +++ b/integrations/oracle_test.go @@ -1,8 +1,8 @@ -// Copyright 20190 The Xorm Authors. All rights reserved. +// 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 oracle +// +build oralce package integrations