Skip to content

Commit

Permalink
Merge pull request #502 from SingularityIT/oracle-batch-support
Browse files Browse the repository at this point in the history
  Implemented batch splitting for Oracle using a single semi-colon on its own line as the delimiter.
  • Loading branch information
tommarien committed Jul 12, 2014
2 parents a38703c + d6056bc commit cfe5307
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/FluentMigrator.Runner/Processors/Oracle/OracleProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Linq;
using System.Text.RegularExpressions;
using FluentMigrator.Runner.Helpers;

#region License
Expand Down Expand Up @@ -198,8 +200,15 @@ protected override void Process(string sql)

EnsureConnectionIsOpen();

using (var command = Factory.CreateCommand(sql, Connection))
command.ExecuteNonQuery();
var batches = Regex.Split(sql, @"^\s*;\s*$", RegexOptions.Multiline)
.Select(x => x.Trim())
.Where(x => !string.IsNullOrEmpty(x));

foreach (var batch in batches)
{
using (var command = Factory.CreateCommand(batch, Connection))
command.ExecuteNonQuery();
}
}
}
}

0 comments on commit cfe5307

Please sign in to comment.