fix bug in oracle: engine.Table(tablename).Exist() (#1227)
This commit is contained in:
parent
1bcc25420d
commit
ee64beb73b
|
@ -42,6 +42,8 @@ func (session *Session) Exist(bean ...interface{}) (bool, error) {
|
||||||
|
|
||||||
if session.engine.dialect.DBType() == core.MSSQL {
|
if session.engine.dialect.DBType() == core.MSSQL {
|
||||||
sqlStr = fmt.Sprintf("SELECT TOP 1 * FROM %s WHERE %s", tableName, condSQL)
|
sqlStr = fmt.Sprintf("SELECT TOP 1 * FROM %s WHERE %s", tableName, condSQL)
|
||||||
|
} else if session.engine.dialect.DBType() == core.ORACLE {
|
||||||
|
sqlStr = fmt.Sprintf("SELECT * FROM %s WHERE (%s) AND ROWNUM=1", tableName, condSQL)
|
||||||
} else {
|
} else {
|
||||||
sqlStr = fmt.Sprintf("SELECT * FROM %s WHERE %s LIMIT 1", tableName, condSQL)
|
sqlStr = fmt.Sprintf("SELECT * FROM %s WHERE %s LIMIT 1", tableName, condSQL)
|
||||||
}
|
}
|
||||||
|
@ -49,6 +51,8 @@ func (session *Session) Exist(bean ...interface{}) (bool, error) {
|
||||||
} else {
|
} else {
|
||||||
if session.engine.dialect.DBType() == core.MSSQL {
|
if session.engine.dialect.DBType() == core.MSSQL {
|
||||||
sqlStr = fmt.Sprintf("SELECT TOP 1 * FROM %s", tableName)
|
sqlStr = fmt.Sprintf("SELECT TOP 1 * FROM %s", tableName)
|
||||||
|
} else if session.engine.dialect.DBType() == core.ORACLE {
|
||||||
|
sqlStr = fmt.Sprintf("SELECT * FROM %s WHERE ROWNUM=1", tableName)
|
||||||
} else {
|
} else {
|
||||||
sqlStr = fmt.Sprintf("SELECT * FROM %s LIMIT 1", tableName)
|
sqlStr = fmt.Sprintf("SELECT * FROM %s LIMIT 1", tableName)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue