Skip to content

Commit 6788018

Browse files
author
Robert Isharjanto
committed
Fix PROC abbreviation match for sql stored procs.
1 parent b989361 commit 6788018

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

DbUp.Support.SqlServer.Scripting/DbObjectScripter.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,17 @@ private IEnumerable<ScriptObject> GetObjectsFromMigrationScripts(SqlScript scrip
125125
//if this group is empty, it means the second part of the regex matched (sp_rename)
126126
if (!string.IsNullOrEmpty(m.Groups[REGEX_INDEX_ACTION_TYPE].Value))
127127
{
128-
129-
if (Enum.TryParse<ObjectTypeEnum>(m.Groups[REGEX_INDEX_OBJECT_TYPE].Value, true, out var type))
128+
if (!Enum.TryParse<ObjectTypeEnum>(m.Groups[REGEX_INDEX_OBJECT_TYPE].Value, true, out var type))
129+
{
130+
//We're adjusting for "PROC" vs "PROCEDURE" since we're checking for it in m_targetDbObjectRegex but it's not an enum member ( "PROCEDURE|PROC" )
131+
if (m.Groups[REGEX_INDEX_OBJECT_TYPE].Value.Equals("PROC", StringComparison.OrdinalIgnoreCase))
132+
{
133+
type = ObjectTypeEnum.Procedure;
134+
}
135+
//else it's ObjectTypeEnum.Undefined
136+
}
137+
138+
if (type != ObjectTypeEnum.Undefined)
130139
{
131140
//replace CREATE OR ALTER by CREATE
132141
var actionString = m.Groups[REGEX_INDEX_ACTION_TYPE].Value.StartsWith(ObjectActionEnum.Create.ToString(), StringComparison.OrdinalIgnoreCase)

0 commit comments

Comments
 (0)