Skip to content

Commit

Permalink
#642 changed delimiter as string. removed obsoleted function
Browse files Browse the repository at this point in the history
  • Loading branch information
ANIL GEORGE committed Jul 29, 2022
1 parent e7d441b commit 56ba0c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/dbup-oracle/OracleCommandSplitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public OracleCommandSplitter()
this.commandReaderFactory = scriptContents => new OracleCommandReader(scriptContents);
}

public OracleCommandSplitter(char delimiter)
public OracleCommandSplitter(string delimiter)
{
this.commandReaderFactory = scriptContents => new OracleCustomDelimiterCommandReader(scriptContents, delimiter);
}
Expand Down
4 changes: 2 additions & 2 deletions src/dbup-oracle/OracleCustomDelimiterCommandReader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text;
using DbUp.Support;

Expand All @@ -11,7 +11,7 @@ public class OracleCustomDelimiterCommandReader : SqlCommandReader
/// <summary>
/// Creates an instance of OracleCommandReader
/// </summary>
public OracleCustomDelimiterCommandReader(string sqlText, char delimiter) : base(sqlText, delimiter.ToString(), delimiterRequiresWhitespace: false)
public OracleCustomDelimiterCommandReader(string sqlText, string delimiter) : base(sqlText, delimiter, delimiterRequiresWhitespace: false)
{
}

Expand Down
28 changes: 10 additions & 18 deletions src/dbup-oracle/OracleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static UpgradeEngineBuilder OracleDatabase(this SupportedDatabases suppor
/// <param name="connectionString"></param>
/// <returns></returns>
public static UpgradeEngineBuilder OracleDatabaseWithDefaultDelimiter(this SupportedDatabases supported, string connectionString)
=> OracleDatabase(supported, connectionString, '/');
=> OracleDatabase(supported, connectionString, "/");

/// <summary>
/// Use ; as the delimiter between statements
Expand All @@ -34,9 +34,9 @@ public static UpgradeEngineBuilder OracleDatabaseWithDefaultDelimiter(this Suppo
/// <param name="connectionString"></param>
/// <returns></returns>
public static UpgradeEngineBuilder OracleDatabaseWithSemicolonDelimiter(this SupportedDatabases supported, string connectionString)
=> OracleDatabase(supported, connectionString, ';');
=> OracleDatabase(supported, connectionString, ";");

public static UpgradeEngineBuilder OracleDatabase(this SupportedDatabases supported, string connectionString, char delimiter)
public static UpgradeEngineBuilder OracleDatabase(this SupportedDatabases supported, string connectionString, string delimiter)
{
foreach (var pair in connectionString.Split(';').Select(s => s.Split('=')).Where(pair => pair.Length == 2).Where(pair => pair[0].ToLower() == "database"))
{
Expand All @@ -46,20 +46,7 @@ public static UpgradeEngineBuilder OracleDatabase(this SupportedDatabases suppor
return OracleDatabase(new OracleConnectionManager(connectionString, new OracleCommandSplitter(delimiter)));
}

/// <summary>
/// Creates an upgrader for Oracle databases.
/// </summary>
/// <param name="supported">Fluent helper type.</param>
/// <param name="connectionString">Oracle database connection string.</param>
/// <param name="schema">Which Oracle schema to check for changes</param>
/// <returns>
/// A builder for a database upgrader designed for Oracle databases.
/// </returns>
[Obsolete("Use the parameter that takes a delimiter instead, see https://github.com/DbUp/DbUp/pull/335")]
public static UpgradeEngineBuilder OracleDatabase(this SupportedDatabases supported, string connectionString, string schema)
{
return OracleDatabase(new OracleConnectionManager(connectionString), schema);
}


/// <summary>
/// Creates an upgrader for Oracle databases.
Expand All @@ -72,7 +59,12 @@ public static UpgradeEngineBuilder OracleDatabase(this SupportedDatabases suppor
/// </returns>
public static UpgradeEngineBuilder OracleDatabase(this SupportedDatabases supported, string connectionString, string schema, string delimiter)
{
return OracleDatabase(new OracleConnectionManager(connectionString), schema);
if (string.IsNullOrWhiteSpace(delimiter))
{
return OracleDatabase(new OracleConnectionManager(connectionString), schema);
}

return OracleDatabase(new OracleConnectionManager(connectionString, new OracleCommandSplitter(delimiter)), schema);
}

/// <summary>
Expand Down

0 comments on commit 56ba0c2

Please sign in to comment.