Fix test
This commit is contained in:
parent
b5665ba1a7
commit
d3348ed165
|
@ -171,7 +171,7 @@ func (db *Base) DropSequenceSQL(seqName string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DropTableSQL returns drop table SQL
|
// DropTableSQL returns drop table SQL
|
||||||
func (db *Base) DropTableSQL(tableName, autoincrCol string) (string, bool) {
|
func (db *Base) DropTableSQL(tableName string) (string, bool) {
|
||||||
quote := db.dialect.Quoter().Quote
|
quote := db.dialect.Quoter().Quote
|
||||||
return fmt.Sprintf("DROP TABLE IF EXISTS %s", quote(tableName)), true
|
return fmt.Sprintf("DROP TABLE IF EXISTS %s", quote(tableName)), true
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,7 +421,7 @@ func (db *mssql) AutoIncrStr() string {
|
||||||
return "IDENTITY"
|
return "IDENTITY"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *mssql) DropTableSQL(tableName, autoincrCol string) (string, bool) {
|
func (db *mssql) DropTableSQL(tableName string) (string, bool) {
|
||||||
return fmt.Sprintf("IF EXISTS (SELECT * FROM sysobjects WHERE id = "+
|
return fmt.Sprintf("IF EXISTS (SELECT * FROM sysobjects WHERE id = "+
|
||||||
"object_id(N'%s') and OBJECTPROPERTY(id, N'IsUserTable') = 1) "+
|
"object_id(N'%s') and OBJECTPROPERTY(id, N'IsUserTable') = 1) "+
|
||||||
"DROP TABLE \"%s\"", tableName, tableName), true
|
"DROP TABLE \"%s\"", tableName, tableName), true
|
||||||
|
|
|
@ -615,7 +615,7 @@ func (db *oracle) IsReserved(name string) bool {
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *oracle) DropTableSQL(tableName, autoincrCol string) (string, bool) {
|
func (db *oracle) DropTableSQL(tableName string) (string, bool) {
|
||||||
return fmt.Sprintf("DROP TABLE %s", db.quoter.Quote(tableName)), false
|
return fmt.Sprintf("DROP TABLE %s", db.quoter.Quote(tableName)), false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -947,12 +947,6 @@ 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":
|
||||||
|
|
|
@ -207,12 +207,6 @@ func (db *sqlite3) SetQuotePolicy(quotePolicy QuotePolicy) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *sqlite3) Features() *DialectFeatures {
|
|
||||||
return &DialectFeatures{
|
|
||||||
AutoincrMode: IncrAutoincrMode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *sqlite3) SQLType(c *schemas.Column) string {
|
func (db *sqlite3) SQLType(c *schemas.Column) string {
|
||||||
switch t := c.SQLType.Name; t {
|
switch t := c.SQLType.Name; t {
|
||||||
case schemas.Bool:
|
case schemas.Bool:
|
||||||
|
|
|
@ -100,11 +100,11 @@ func (statement *Statement) GenInsertSQL(colNames []string, args []interface{})
|
||||||
if needSeq {
|
if needSeq {
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
if _, err := buf.WriteString(","); err != nil {
|
if _, err := buf.WriteString(","); err != nil {
|
||||||
return "", nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, err := buf.WriteString(utils.SeqName(tableName) + ".nextval"); err != nil {
|
if _, err := buf.WriteString(utils.SeqName(tableName) + ".nextval"); err != nil {
|
||||||
return "", nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(exprs) > 0 {
|
if len(exprs) > 0 {
|
||||||
|
@ -112,7 +112,7 @@ func (statement *Statement) GenInsertSQL(colNames []string, args []interface{})
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := exprs.WriteArgs(buf); err != nil {
|
if err := exprs.WriteArgs(buf); err != nil {
|
||||||
return "", nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,11 +144,11 @@ func (statement *Statement) GenInsertSQL(colNames []string, args []interface{})
|
||||||
if needSeq {
|
if needSeq {
|
||||||
if hasInsertColumns {
|
if hasInsertColumns {
|
||||||
if _, err := buf.WriteString(","); err != nil {
|
if _, err := buf.WriteString(","); err != nil {
|
||||||
return "", nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, err := buf.WriteString(utils.SeqName(tableName) + ".nextval"); err != nil {
|
if _, err := buf.WriteString(utils.SeqName(tableName) + ".nextval"); err != nil {
|
||||||
return "", nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,7 @@ func (session *Session) insertStruct(bean interface{}) (int64, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
sqlStr = session.engine.dialect.Quoter().Replace(sqlStr)
|
var sqlStr = session.engine.dialect.Quoter().Replace(buf.String())
|
||||||
|
|
||||||
handleAfterInsertProcessorFunc := func(bean interface{}) {
|
handleAfterInsertProcessorFunc := func(bean interface{}) {
|
||||||
if session.isAutoCommit {
|
if session.isAutoCommit {
|
||||||
|
|
|
@ -148,14 +148,11 @@ func (session *Session) DropTable(beanOrTableName interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) dropTable(beanOrTableName interface{}) error {
|
func (session *Session) dropTable(beanOrTableName interface{}) error {
|
||||||
var tableName, autoIncrementCol string
|
var tableName string
|
||||||
switch beanOrTableName.(type) {
|
switch beanOrTableName.(type) {
|
||||||
case *schemas.Table:
|
case *schemas.Table:
|
||||||
table := beanOrTableName.(*schemas.Table)
|
table := beanOrTableName.(*schemas.Table)
|
||||||
tableName = table.Name
|
tableName = table.Name
|
||||||
if table.AutoIncrColumn() != nil {
|
|
||||||
autoIncrementCol = table.AutoIncrColumn().Name
|
|
||||||
}
|
|
||||||
case string:
|
case string:
|
||||||
tableName = beanOrTableName.(string)
|
tableName = beanOrTableName.(string)
|
||||||
default:
|
default:
|
||||||
|
@ -169,12 +166,9 @@ func (session *Session) dropTable(beanOrTableName interface{}) error {
|
||||||
} else {
|
} else {
|
||||||
tableName = table.Name
|
tableName = table.Name
|
||||||
}
|
}
|
||||||
if table.AutoIncrColumn() != nil {
|
|
||||||
autoIncrementCol = table.AutoIncrColumn().Name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlStr, checkIfExist := session.engine.dialect.DropTableSQL(tableName, autoIncrementCol)
|
sqlStr, checkIfExist := session.engine.dialect.DropTableSQL(tableName)
|
||||||
if !checkIfExist {
|
if !checkIfExist {
|
||||||
exist, err := session.engine.dialect.IsTableExist(session.getQueryer(), session.ctx, tableName)
|
exist, err := session.engine.dialect.IsTableExist(session.getQueryer(), session.ctx, tableName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -189,10 +183,7 @@ func (session *Session) dropTable(beanOrTableName interface{}) error {
|
||||||
if _, err := session.exec(sqlStr); err != nil {
|
if _, err := session.exec(sqlStr); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 1805a60 (Fix test)
|
|
||||||
if session.engine.dialect.Features().AutoincrMode == dialects.IncrAutoincrMode {
|
if session.engine.dialect.Features().AutoincrMode == dialects.IncrAutoincrMode {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue