Skip to content

Commit

Permalink
Fix PROC abbreviation match for sql stored procs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Isharjanto committed Jan 24, 2020
1 parent b989361 commit 6788018
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions DbUp.Support.SqlServer.Scripting/DbObjectScripter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,17 @@ private IEnumerable<ScriptObject> GetObjectsFromMigrationScripts(SqlScript scrip
//if this group is empty, it means the second part of the regex matched (sp_rename)
if (!string.IsNullOrEmpty(m.Groups[REGEX_INDEX_ACTION_TYPE].Value))
{

if (Enum.TryParse<ObjectTypeEnum>(m.Groups[REGEX_INDEX_OBJECT_TYPE].Value, true, out var type))
if (!Enum.TryParse<ObjectTypeEnum>(m.Groups[REGEX_INDEX_OBJECT_TYPE].Value, true, out var type))
{
//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" )
if (m.Groups[REGEX_INDEX_OBJECT_TYPE].Value.Equals("PROC", StringComparison.OrdinalIgnoreCase))
{
type = ObjectTypeEnum.Procedure;
}
//else it's ObjectTypeEnum.Undefined
}

if (type != ObjectTypeEnum.Undefined)
{
//replace CREATE OR ALTER by CREATE
var actionString = m.Groups[REGEX_INDEX_ACTION_TYPE].Value.StartsWith(ObjectActionEnum.Create.ToString(), StringComparison.OrdinalIgnoreCase)
Expand Down

0 comments on commit 6788018

Please sign in to comment.