-
Notifications
You must be signed in to change notification settings - Fork 4
/
SnowflakeConnectionManager.cs
37 lines (33 loc) · 1.21 KB
/
SnowflakeConnectionManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using DbUp.Engine.Transactions;
namespace DbUp.Snowflake
{
/// <summary>
/// Manages Snowflake database connections.
/// </summary>
public class SnowflakeConnectionManager : DatabaseConnectionManager
{
/// <summary>
/// Creates a new Snowflake database connection.
/// </summary>
/// <param name="connectionString">The Snowflake connection string.</param>
public SnowflakeConnectionManager(string connectionString) : base(new SnowflakeConnectionFactory(connectionString))
{
}
/// <summary>
/// Splits the statements in the script using the ";" character.
/// </summary>
/// <param name="scriptContents">The contents of the script to split.</param>
public override IEnumerable<string> SplitScriptIntoCommands(string scriptContents)
{
var scriptStatements =
Regex.Split(scriptContents, ";(?=(?:[^']*'[^']*')*[^']*$)")
.Select(x => x.Trim())
.Where(x => x.Length > 0)
.ToArray();
return scriptStatements;
}
}
}