Fix test
This commit is contained in:
parent
1bbf4ffc83
commit
3e45120160
10
Makefile
10
Makefile
|
@ -162,19 +162,13 @@ $(DB2_DRIVER_DIR):
|
||||||
|
|
||||||
.PNONY: test-db2
|
.PNONY: test-db2
|
||||||
test-db2: go-check $(DB2_DRIVER_DIR)
|
test-db2: go-check $(DB2_DRIVER_DIR)
|
||||||
CGO_CFLAGS=-I$(DB2_DRIVER_DIR)/include \
|
$(GO) test $(INTEGRATION_PACKAGES) -v -tags=db2 -db=go_ibm_db -cache=$(TEST_CACHE_ENABLE) \
|
||||||
CGO_LDFLAGS=-L$(DB2_DRIVER_DIR)/lib \
|
|
||||||
DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH):$(DB2_DRIVER_DIR)/lib \
|
|
||||||
$(GO) test -race -db=go_ibm_db -tags=db2 -cache=$(TEST_CACHE_ENABLE) \
|
|
||||||
-conn_str="HOSTNAME=$(TEST_DB2_HOST);DATABASE=$(TEST_DB2_DBNAME);PORT=$(TEST_DB2_PORT);UID=$(TEST_DB2_USERNAME);PWD=$(TEST_DB2_PASSWORD)" \
|
-conn_str="HOSTNAME=$(TEST_DB2_HOST);DATABASE=$(TEST_DB2_DBNAME);PORT=$(TEST_DB2_PORT);UID=$(TEST_DB2_USERNAME);PWD=$(TEST_DB2_PASSWORD)" \
|
||||||
-coverprofile=db2.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
-coverprofile=db2.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
.PNONY: test-db2\#%
|
.PNONY: test-db2\#%
|
||||||
test-db2\#%: go-check
|
test-db2\#%: go-check
|
||||||
CGO_CFLAGS=-I$(DB2_DRIVER_DIR)/include \
|
$(GO) test $(INTEGRATION_PACKAGES) -v -run $* -db=go_ibm_db -tags=db2 -cache=$(TEST_CACHE_ENABLE) \
|
||||||
CGO_LDFLAGS=-L$(DB2_DRIVER_DIR)/lib \
|
|
||||||
DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH):$(DB2_DRIVER_DIR)/lib \
|
|
||||||
$(GO) test -race -run $* -db=go_ibm_db -tags=db2 -cache=$(TEST_CACHE_ENABLE) \
|
|
||||||
-conn_str="HOSTNAME=$(TEST_DB2_HOST);DATABASE=$(TEST_DB2_DBNAME);PORT=$(TEST_DB2_PORT);UID=$(TEST_DB2_USERNAME);PWD=$(TEST_DB2_PASSWORD)" \
|
-conn_str="HOSTNAME=$(TEST_DB2_HOST);DATABASE=$(TEST_DB2_DBNAME);PORT=$(TEST_DB2_PORT);UID=$(TEST_DB2_USERNAME);PWD=$(TEST_DB2_PASSWORD)" \
|
||||||
-coverprofile=db2.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
-coverprofile=db2.$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,10 @@ func (db *db2) SQLType(c *schemas.Column) string {
|
||||||
case schemas.TinyInt:
|
case schemas.TinyInt:
|
||||||
res = schemas.SmallInt
|
res = schemas.SmallInt
|
||||||
return res
|
return res
|
||||||
|
case schemas.UnsignedBigInt:
|
||||||
|
res = schemas.BigInt
|
||||||
|
case schemas.UnsignedInt:
|
||||||
|
res = schemas.BigInt
|
||||||
case schemas.Bit:
|
case schemas.Bit:
|
||||||
res = schemas.Boolean
|
res = schemas.Boolean
|
||||||
return res
|
return res
|
||||||
|
@ -180,9 +184,9 @@ func (db *db2) SetQuotePolicy(quotePolicy QuotePolicy) {
|
||||||
|
|
||||||
func (db *db2) IsTableExist(queryer core.Queryer, ctx context.Context, tableName string) (bool, error) {
|
func (db *db2) IsTableExist(queryer core.Queryer, ctx context.Context, tableName string) (bool, error) {
|
||||||
if len(db.uri.Schema) == 0 {
|
if len(db.uri.Schema) == 0 {
|
||||||
return db.HasRecords(queryer, ctx, `SELECT tablename FROM pg_tables WHERE tablename = ?`, tableName)
|
return db.HasRecords(queryer, ctx, `SELECT tabname FROM syscat.tables WHERE tabname = ?`, tableName)
|
||||||
}
|
}
|
||||||
return db.HasRecords(queryer, ctx, `SELECT tablename FROM pg_tables WHERE schemaname = ? AND tablename = ?`,
|
return db.HasRecords(queryer, ctx, `SELECT tabname FROM syscat.tables WHERE tabschema = ? AND tabname = ?`,
|
||||||
db.uri.Schema, tableName,
|
db.uri.Schema, tableName,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -196,6 +200,12 @@ func (db *db2) ModifyColumnSQL(tableName string, col *schemas.Column) string {
|
||||||
db.uri.Schema, tableName, col.Name, db.SQLType(col))
|
db.uri.Schema, tableName, col.Name, db.SQLType(col))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DropTableSQL returns drop table SQL
|
||||||
|
func (db *db2) DropTableSQL(tableName string) (string, bool) {
|
||||||
|
quote := db.Quoter().Quote
|
||||||
|
return fmt.Sprintf("DROP TABLE %s", quote(tableName)), false
|
||||||
|
}
|
||||||
|
|
||||||
func (db *db2) DropIndexSQL(tableName string, index *schemas.Index) string {
|
func (db *db2) DropIndexSQL(tableName string, index *schemas.Index) string {
|
||||||
quote := db.Quoter().Quote
|
quote := db.Quoter().Quote
|
||||||
idxName := index.Name
|
idxName := index.Name
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
// +build db2
|
// +build db2
|
||||||
|
|
||||||
package xorm
|
package integrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "github.com/ibmdb/go_ibm_db"
|
_ "github.com/ibmdb/go_ibm_db"
|
11
test_db2.sh
11
test_db2.sh
|
@ -1,11 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
go get -d github.com/ibmdb/go_ibm_db
|
|
||||||
export DB2HOME=$GOPATH/src/github.com/ibmdb/go_ibm_db/installer
|
|
||||||
cur="$PWD"
|
|
||||||
cd $DB2HOME && go run setup.go
|
|
||||||
export CGO_CFLAGS=-I$DB2HOME/include
|
|
||||||
export CGO_LDFLAGS=-L$DB2HOME/lib
|
|
||||||
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$DB2HOME/clidriver/lib
|
|
||||||
cd $cur
|
|
||||||
go test -db=go_ibm_db -tags=db2 -conn_str="HOSTNAME=localhost;DATABASE=testdb;PORT=50000;UID=db2inst1;PWD=123#2@23"
|
|
Loading…
Reference in New Issue