fix drop index SQL for Oracle (#2469)

Adjust drop index SQL to work with Oracle Autonomous DB

Issue:
DROP INDEX IDX_casdoor_permission_rule_PTYPE ON casdoor_permission_rule
Error report -
ORA-00933: SQL command not properly ended

Expected:
DROP INDEX IDX_casdoor_permission_rule_PTYPE

Co-authored-by: Cenxiao Zhao <cenxiao@projectboard.world>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2469
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: cenxiao <cenxiao@noreply.gitea.com>
Co-committed-by: cenxiao <cenxiao@noreply.gitea.com>
This commit is contained in:
cenxiao 2025-02-28 06:26:20 +00:00 committed by Lunny Xiao
parent 7654b7b749
commit 844543c7da
1 changed files with 11 additions and 0 deletions

View File

@ -684,6 +684,17 @@ func (db *oracle) IndexCheckSQL(tableName, idxName string) (string, []interface{
`WHERE TABLE_NAME = :1 AND INDEX_NAME = :2`, args
}
func (db *oracle) DropIndexSQL(tableName string, index *schemas.Index) string {
quote := db.dialect.Quoter().Quote
var name string
if index.IsRegular {
name = index.XName(tableName)
} else {
name = index.Name
}
return fmt.Sprintf("DROP INDEX %v", quote(name))
}
func (db *oracle) IsTableExist(queryer core.Queryer, ctx context.Context, tableName string) (bool, error) {
return db.HasRecords(queryer, ctx, `SELECT table_name FROM user_tables WHERE table_name = :1`, tableName)
}