Add oracle tests #1463

Closed
lunny wants to merge 24 commits from lunny/test_oracle2 into master
4 changed files with 12 additions and 17 deletions
Showing only changes of commit 84d1a51434 - Show all commits

View File

@ -45,8 +45,7 @@ const (
// DialectFeatures represents the features that the dialect supports // DialectFeatures represents the features that the dialect supports
type DialectFeatures struct { type DialectFeatures struct {
AutoincrMode int // 0 autoincrement column, 1 sequence AutoincrMode int // 0 autoincrement column, 1 sequence
SupportReturnIDWhenInsert bool
} }
// Dialect represents a kind of database // Dialect represents a kind of database

View File

@ -15,6 +15,7 @@ import (
"strings" "strings"
"xorm.io/xorm/core" "xorm.io/xorm/core"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas" "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 { func (db *oracle) Features() *DialectFeatures {
return &DialectFeatures{ return &DialectFeatures{
AutoincrMode: SequenceAutoincrMode, AutoincrMode: SequenceAutoincrMode,
SupportReturnIDWhenInsert: false,
} }
} }
@ -688,10 +688,6 @@ func (db *oracle) IsColumnExist(queryer core.Queryer, ctx context.Context, table
return db.HasRecords(queryer, ctx, query, args...) 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) { 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," + //s := "SELECT column_name,data_default,data_type,data_length,data_precision,data_scale," +
// "nullable FROM USER_TAB_COLUMNS WHERE table_name = :1" // "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 { if pkName != "" && pkName == col.Name {
col.IsPrimaryKey = true 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 { if err != nil {
return nil, nil, err return nil, nil, err
} }

View File

@ -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 { func (db *postgres) SQLType(c *schemas.Column) string {
var res string var res string
switch t := c.SQLType.Name; t { switch t := c.SQLType.Name; t {
@ -947,6 +941,12 @@ func (db *postgres) SQLType(c *schemas.Column) string {
return res return res
} }
func (db *postgres) Features() *DialectFeatures {
return &DialectFeatures{
AutoincrMode: IncrAutoincrMode,
}
}
func (db *postgres) ColumnTypeKind(t string) int { func (db *postgres) ColumnTypeKind(t string) int {
switch strings.ToUpper(t) { switch strings.ToUpper(t) {
case "DATETIME", "TIMESTAMP": case "DATETIME", "TIMESTAMP":

View File

@ -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 // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build oracle // +build oralce
package integrations package integrations