Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 支持使用create or replace创建函数、存储过程、视图以及包等语句 #2066

Merged
merged 9 commits into from
Mar 11, 2023
20 changes: 10 additions & 10 deletions sql/engines/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,25 +457,25 @@ def get_sql_first_object_name(sql=""):
object_name = re.match(
r"^alter\s+table\s(.+?)\s", sql, re.M | re.IGNORECASE
).group(1)
elif re.match(r"^create\s+function\s", sql, re.M | re.IGNORECASE):
elif re.match(r"^create\s+[or\s]+[replace\s]+function\s", sql, re.M | re.IGNORECASE):
object_name = re.match(
r"^create\s+function\s(.+?)(\s|\()", sql, re.M | re.IGNORECASE
r"^create\s+[or\s]+[replace\s]+function\s(.+?)(\s|\()", sql, re.M | re.IGNORECASE
).group(1)
elif re.match(r"^create\s+view\s", sql, re.M | re.IGNORECASE):
elif re.match(r"^create\s+[or\s]+[replace\s]+view\s", sql, re.M | re.IGNORECASE):
object_name = re.match(
r"^create\s+view\s(.+?)\s", sql, re.M | re.IGNORECASE
r"^create\s+[or\s]+[replace\s]+view\s(.+?)\s", sql, re.M | re.IGNORECASE
).group(1)
elif re.match(r"^create\s+procedure\s", sql, re.M | re.IGNORECASE):
elif re.match(r"^create\s+[or\s]+[replace\s]+procedure\s", sql, re.M | re.IGNORECASE):
object_name = re.match(
r"^create\s+procedure\s(.+?)\s", sql, re.M | re.IGNORECASE
r"^create\s+[or\s]+[replace\s]+procedure\s(.+?)\s", sql, re.M | re.IGNORECASE
).group(1)
elif re.match(r"^create\s+package\s+body", sql, re.M | re.IGNORECASE):
elif re.match(r"^create\s+[or\s]+[replace\s]+package\s+body", sql, re.M | re.IGNORECASE):
object_name = re.match(
r"^create\s+package\s+body\s(.+?)\s", sql, re.M | re.IGNORECASE
r"^create\s+[or\s]+[replace\s]+package\s+body\s(.+?)\s", sql, re.M | re.IGNORECASE
).group(1)
elif re.match(r"^create\s+package\s", sql, re.M | re.IGNORECASE):
elif re.match(r"^create\s+[or\s]+[replace\s]+package\s", sql, re.M | re.IGNORECASE):
object_name = re.match(
r"^create\s+package\s(.+?)\s", sql, re.M | re.IGNORECASE
r"^create\s+[or\s]+[replace\s]+package\s(.+?)\s", sql, re.M | re.IGNORECASE
).group(1)
LeoQuote marked this conversation as resolved.
Show resolved Hide resolved
else:
return object_name.strip()
Expand Down