From 844543c7daa40a7a52d85996fa0a1e782da660c3 Mon Sep 17 00:00:00 2001 From: cenxiao Date: Fri, 28 Feb 2025 06:26:20 +0000 Subject: [PATCH] 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 Co-authored-by: Lunny Xiao Reviewed-on: https://gitea.com/xorm/xorm/pulls/2469 Reviewed-by: Lunny Xiao Co-authored-by: cenxiao Co-committed-by: cenxiao --- dialects/oracle.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dialects/oracle.go b/dialects/oracle.go index 5f614b1a..0170bcae 100644 --- a/dialects/oracle.go +++ b/dialects/oracle.go @@ -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) }