Skip to content

Commit

Permalink
Bump Oracle.ManagedDataAccess.Core from 23.5.0 to 23.5.1 (#297)
Browse files Browse the repository at this point in the history
* Bump Oracle.ManagedDataAccess.Core from 23.5.0 to 23.5.1

Bumps Oracle.ManagedDataAccess.Core from 23.5.0 to 23.5.1.

---
updated-dependencies:
- dependency-name: Oracle.ManagedDataAccess.Core
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Test cleanup

* Down to 40 IDE warnings...

* Iterator fix

* Update MicrosoftSQLTableHelper.cs

Check connection is open before using it

* Update DiscoveredTableValuedFunction.cs

Make sure connection is open before using it!

* Update DiscoveredTableValuedFunction.cs

Enumerable fixups

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: James A Sutherland <[email protected]>
  • Loading branch information
dependabot[bot] and jas88 authored Aug 17, 2024
1 parent fc04ffd commit d1282ef
Show file tree
Hide file tree
Showing 44 changed files with 395 additions and 466 deletions.
6 changes: 3 additions & 3 deletions FAnsiSql/Discovery/DiscoveredDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public DiscoveredTable ExpectTable(string tableName, string? schema = null, Tabl
/// Connects to the database and returns a list of stored proceedures found as <see cref="DiscoveredStoredprocedure"/> objects
/// </summary>
/// <returns></returns>
public DiscoveredStoredprocedure[] DiscoverStoredprocedures() => Helper.ListStoredprocedures(Server.Builder,GetRuntimeName());
public IEnumerable<DiscoveredStoredprocedure> DiscoverStoredprocedures() => Helper.ListStoredprocedures(Server.Builder,GetRuntimeName());

/// <summary>
/// Returns the name of the database
Expand Down Expand Up @@ -231,7 +231,7 @@ public DiscoveredTable CreateTable(string tableName, DataTable dt, DatabaseColum
/// <param name="createEmpty"></param>
/// <param name="adjuster"></param>
/// <returns></returns>
public DiscoveredTable CreateTable(out Dictionary<string, Guesser> typeDictionary, string tableName, DataTable dt, DatabaseColumnRequest[]? explicitColumnDefinitions = null, bool createEmpty = false, IDatabaseColumnRequestAdjuster? adjuster = null)
public DiscoveredTable CreateTable(out Dictionary<string, Guesser>? typeDictionary, string tableName, DataTable dt, DatabaseColumnRequest[]? explicitColumnDefinitions = null, bool createEmpty = false, IDatabaseColumnRequestAdjuster? adjuster = null)
{
var args = new CreateTableArgs(this, tableName, null, dt, createEmpty)
{
Expand All @@ -240,7 +240,7 @@ public DiscoveredTable CreateTable(out Dictionary<string, Guesser> typeDictionar
};
var table = Helper.CreateTable(args);

if(!args.TableCreated)
if (!args.TableCreated)
throw new Exception(FAnsiStrings.DiscoveredDatabase_CreateTableDidNotPopulateTableCreatedProperty);

typeDictionary = args.ColumnCreationLogic;
Expand Down
2 changes: 1 addition & 1 deletion FAnsiSql/Discovery/DiscoveredDatabaseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract IEnumerable<DiscoveredTable> ListTables(DiscoveredDatabase paren
public abstract IEnumerable<DiscoveredTableValuedFunction> ListTableValuedFunctions(DiscoveredDatabase parent, IQuerySyntaxHelper querySyntaxHelper,
DbConnection connection, string database, DbTransaction? transaction = null);

public abstract DiscoveredStoredprocedure[] ListStoredprocedures(DbConnectionStringBuilder builder, string database);
public abstract IEnumerable<DiscoveredStoredprocedure> ListStoredprocedures(DbConnectionStringBuilder builder, string database);
public abstract IDiscoveredTableHelper GetTableHelper();
public abstract void DropDatabase(DiscoveredDatabase database);
public abstract Dictionary<string, string> DescribeDatabase(DbConnectionStringBuilder builder, string database);
Expand Down
2 changes: 1 addition & 1 deletion FAnsiSql/Discovery/DiscoveredServerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public DbConnectionStringBuilder ChangeServer(DbConnectionStringBuilder builder,
return builder;
}

public virtual string GetCurrentDatabase(DbConnectionStringBuilder builder) => (string)builder[DatabaseKeyName];
public virtual string? GetCurrentDatabase(DbConnectionStringBuilder builder) => (string)builder[DatabaseKeyName];

public virtual DbConnectionStringBuilder ChangeDatabase(DbConnectionStringBuilder builder, string newDatabase)
{
Expand Down
4 changes: 2 additions & 2 deletions FAnsiSql/Discovery/DiscoveredTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public virtual bool Exists(IManagedTransaction? transaction = null)
public DiscoveredColumn[] DiscoverColumns(IManagedTransaction? managedTransaction = null)
{
using var connection = Database.Server.GetManagedConnection(managedTransaction);
return Helper.DiscoverColumns(this, connection, Database.GetRuntimeName());
return Helper.DiscoverColumns(this, connection, Database.GetRuntimeName()).ToArray();
}

/// <summary>
Expand Down Expand Up @@ -505,7 +505,7 @@ public int Insert(Dictionary<string, object> toInsert, CultureInfo? culture, IMa
public DiscoveredRelationship[] DiscoverRelationships(IManagedTransaction? transaction = null)
{
using var connection = Database.Server.GetManagedConnection(transaction);
return Helper.DiscoverRelationships(this, connection.Connection, transaction);
return Helper.DiscoverRelationships(this, connection.Connection, transaction).ToArray();
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions FAnsiSql/Discovery/DiscoveredTableHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class DiscoveredTableHelper : IDiscoveredTableHelper
{
public abstract string GetTopXSqlForTable(IHasFullyQualifiedNameToo table, int topX);

public abstract DiscoveredColumn[] DiscoverColumns(DiscoveredTable discoveredTable, IManagedConnection connection, string database);
public abstract IEnumerable<DiscoveredColumn> DiscoverColumns(DiscoveredTable discoveredTable, IManagedConnection connection, string database);

public abstract IDiscoveredColumnHelper GetColumnHelper();
public virtual void DropTable(DbConnection connection, DiscoveredTable tableToDrop)
Expand Down Expand Up @@ -56,7 +56,7 @@ public virtual int GetRowCount(DatabaseOperationArgs args, DiscoveredTable table
return Convert.ToInt32(args.ExecuteScalar(cmd));
}

public abstract IEnumerable<DiscoveredParameter> DiscoverTableValuedFunctionParameters(DbConnection connection, DiscoveredTableValuedFunction discoveredTableValuedFunction, DbTransaction transaction);
public abstract IEnumerable<DiscoveredParameter> DiscoverTableValuedFunctionParameters(DbConnection connection, DiscoveredTableValuedFunction discoveredTableValuedFunction, DbTransaction? transaction);

public abstract IBulkCopy BeginBulkInsert(DiscoveredTable discoveredTable, IManagedConnection connection, CultureInfo culture);

Expand Down Expand Up @@ -201,7 +201,7 @@ public virtual int ExecuteInsertReturningIdentity(DiscoveredTable discoveredTabl
return Convert.ToInt32(result);
}

public abstract DiscoveredRelationship[] DiscoverRelationships(DiscoveredTable table, DbConnection connection, IManagedTransaction? transaction = null);
public abstract IEnumerable<DiscoveredRelationship> DiscoverRelationships(DiscoveredTable table, DbConnection connection, IManagedTransaction? transaction = null);

public virtual void FillDataTableWithTopX(DatabaseOperationArgs args, DiscoveredTable table, int topX, DataTable dt)
{
Expand Down
4 changes: 3 additions & 1 deletion FAnsiSql/Discovery/DiscoveredTableValuedFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public override void Drop()
public IEnumerable<DiscoveredParameter> DiscoverParameters(ManagedTransaction? transaction = null)
{
using var connection = Database.Server.GetManagedConnection(transaction);
return Helper.DiscoverTableValuedFunctionParameters(connection.Connection, this, connection.Transaction);
foreach (var param in Helper.DiscoverTableValuedFunctionParameters(connection.Connection, this,
connection.Transaction))
yield return param;
}
}
3 changes: 1 addition & 2 deletions FAnsiSql/Discovery/IDiscoveredDatabaseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ namespace FAnsi.Discovery;
/// </summary>
public interface IDiscoveredDatabaseHelper
{

IEnumerable<DiscoveredTable> ListTables(DiscoveredDatabase parent, IQuerySyntaxHelper querySyntaxHelper, DbConnection connection, string database, bool includeViews, DbTransaction? transaction = null);
IEnumerable<DiscoveredTableValuedFunction> ListTableValuedFunctions(DiscoveredDatabase parent, IQuerySyntaxHelper querySyntaxHelper, DbConnection connection, string database, DbTransaction? transaction = null);

DiscoveredStoredprocedure[] ListStoredprocedures(DbConnectionStringBuilder builder, string database);
IEnumerable<DiscoveredStoredprocedure> ListStoredprocedures(DbConnectionStringBuilder builder, string database);

IDiscoveredTableHelper GetTableHelper();
void DropDatabase(DiscoveredDatabase database);
Expand Down
2 changes: 1 addition & 1 deletion FAnsiSql/Discovery/IDiscoveredServerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface IDiscoveredServerHelper
string? GetServerName(DbConnectionStringBuilder builder);
DbConnectionStringBuilder ChangeServer(DbConnectionStringBuilder builder, string newServer);

string GetCurrentDatabase(DbConnectionStringBuilder builder);
string? GetCurrentDatabase(DbConnectionStringBuilder builder);
DbConnectionStringBuilder ChangeDatabase(DbConnectionStringBuilder builder, string newDatabase);

DbConnectionStringBuilder EnableAsync(DbConnectionStringBuilder builder);
Expand Down
6 changes: 3 additions & 3 deletions FAnsiSql/Discovery/IDiscoveredTableHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IDiscoveredTableHelper
/// <param name="table">The table to fetch records from</param>
string GetTopXSqlForTable(IHasFullyQualifiedNameToo table, int topX);

DiscoveredColumn[] DiscoverColumns(DiscoveredTable discoveredTable, IManagedConnection connection, string database);
IEnumerable<DiscoveredColumn> DiscoverColumns(DiscoveredTable discoveredTable, IManagedConnection connection, string database);

IDiscoveredColumnHelper GetColumnHelper();

Expand All @@ -29,7 +29,7 @@ public interface IDiscoveredTableHelper

int GetRowCount(DatabaseOperationArgs args, DiscoveredTable table);

IEnumerable<DiscoveredParameter> DiscoverTableValuedFunctionParameters(DbConnection connection, DiscoveredTableValuedFunction discoveredTableValuedFunction, DbTransaction transaction);
IEnumerable<DiscoveredParameter> DiscoverTableValuedFunctionParameters(DbConnection connection, DiscoveredTableValuedFunction discoveredTableValuedFunction, DbTransaction? transaction);

IBulkCopy BeginBulkInsert(DiscoveredTable discoveredTable, IManagedConnection connection,CultureInfo culture);

Expand All @@ -45,7 +45,7 @@ public interface IDiscoveredTableHelper
void DropIndex(DatabaseOperationArgs args, DiscoveredTable table, string indexName);
void CreatePrimaryKey(DatabaseOperationArgs args, DiscoveredTable columns, DiscoveredColumn[] discoverColumns);
int ExecuteInsertReturningIdentity(DiscoveredTable discoveredTable, DbCommand cmd, IManagedTransaction? transaction=null);
DiscoveredRelationship[] DiscoverRelationships(DiscoveredTable discoveredTable,DbConnection connection, IManagedTransaction? transaction = null);
IEnumerable<DiscoveredRelationship> DiscoverRelationships(DiscoveredTable discoveredTable,DbConnection connection, IManagedTransaction? transaction = null);
void FillDataTableWithTopX(DatabaseOperationArgs args,DiscoveredTable table, int topX, DataTable dt);


Expand Down
4 changes: 2 additions & 2 deletions FAnsiSql/Discovery/QuerySyntax/Aggregation/IQueryAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace FAnsi.Discovery.QuerySyntax.Aggregation;
/// </summary>
public interface IQueryAxis
{
string EndDate { get; }
string StartDate { get; }
string? EndDate { get; }
string? StartDate { get; }
AxisIncrement AxisIncrement { get; }
}
4 changes: 2 additions & 2 deletions FAnsiSql/Discovery/QuerySyntax/Aggregation/QueryAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace FAnsi.Discovery.QuerySyntax.Aggregation;
public sealed class QueryAxis : IQueryAxis
{
/// <inheritdoc/>
public string EndDate { get; set; }
public string? EndDate { get; set; }
/// <inheritdoc/>
public string StartDate { get; set; }
public string? StartDate { get; set; }
/// <inheritdoc/>
public AxisIncrement AxisIncrement { get; set; }
}
2 changes: 1 addition & 1 deletion FAnsiSql/Discovery/QuerySyntax/CustomLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public string GetTextWithoutAlias(IQuerySyntaxHelper syntaxHelper)
/// </summary>
/// <param name="syntaxHelper"></param>
/// <returns></returns>
public string GetAliasFromText(IQuerySyntaxHelper syntaxHelper)
public string? GetAliasFromText(IQuerySyntaxHelper syntaxHelper)
{
syntaxHelper.SplitLineIntoSelectSQLAndAlias(Text, out _, out var alias);
return string.IsNullOrWhiteSpace(alias) ? null : alias;
Expand Down
27 changes: 12 additions & 15 deletions FAnsiSql/Discovery/QuerySyntaxHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,6 @@ public abstract partial class QuerySyntaxHelper(

public virtual char ParameterSymbol => '@';

/// <summary>
/// Returns a regex that picks up alias specifications in SELECT sql (e.g. "mytbl.mycol as fish"). This only has to match when the
/// " AS " qualifier is used explicitly. The capture groups of this Regex must match <see cref="SplitLineIntoSelectSQLAndAlias"/>
/// </summary>
/// <returns></returns>
private Regex GetAliasRegex() =>
//whitespace followed by as and more whitespace
//Then any word (optionally bounded by a table name qualifier)
//alias is a word
//(w+)
//alias is a wrapped word e.g. [hey hey]. In this case we must allow anything between the brackets that is not closing bracket
//[[`""]([^[`""]+)[]`""]
AliasRegex();

private static string GetAliasConst() => " AS ";

public string AliasPrefix => GetAliasConst();
Expand Down Expand Up @@ -207,7 +193,7 @@ public virtual bool SplitLineIntoSelectSQLAndAlias(string lineToSplit, out strin
//Ths line is expected to be some SELECT sql so remove trailing whitespace and commas etc
lineToSplit = lineToSplit.TrimEnd(',', ' ', '\n', '\r');

var matches = GetAliasRegex().Matches(lineToSplit);
var matches = AliasRegex().Matches(lineToSplit);

switch (matches.Count)
{
Expand Down Expand Up @@ -499,14 +485,25 @@ public Dictionary<T, string> GetParameterNamesFor<T>(T[] columns, Func<T, string

[GeneratedRegex(@"^\w*$")]
private static partial Regex sensibleParameterNamesIncludeRe();

//whitespace followed by as and more whitespace
//Then any word (optionally bounded by a table name qualifier)
//alias is a word
//(w+)
//alias is a wrapped word e.g. [hey hey]. In this case we must allow anything between the brackets that is not closing bracket
//[[`""]([^[`""]+)[]`""]
[GeneratedRegex("""\s+as\s+((\w+)|([[`"]([^[`"]+)[]`"]))$""", RegexOptions.IgnoreCase, "en-US")]
private static partial Regex AliasRegex();

[GeneratedRegex("([@:][A-Za-z0-9_]*)\\s?", RegexOptions.IgnoreCase, "en-US")]
private static partial Regex ParameterNamesRe();

[GeneratedRegex("[^A-Za-z0-9_ \u0101-\uFFFF]")]
private static partial Regex HeaderNameCharRegex();

[GeneratedRegex("^[0-9]")]
private static partial Regex StartsDigitsRe();

[GeneratedRegex("[^A-Za-z0-9_]")]
private static partial Regex NotAlphaNumRe();
}
8 changes: 4 additions & 4 deletions FAnsiSql/Discovery/TableCreation/CreateTableArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public sealed class CreateTableArgs(DiscoveredDatabase database, string tableNam
/// <summary>
/// Schema of the <see cref="Database"/> to create the table in. This is NOT the database e.g. in [MyDb].[dbo].[MyTable] the schema is "dbo". If in doubt leave blank
/// </summary>
public string Schema { get; private set; } = schema;
public string? Schema { get; private set; } = schema;

/// <summary>
/// Optional - Columns are normally created based on supplied DataTable data rows. If this is set then the Type specified here will
Expand All @@ -47,7 +47,7 @@ public sealed class CreateTableArgs(DiscoveredDatabase database, string tableNam
/// Key is the foreign key column (and the table the constraint will be put on).
/// Value is the primary key table column (which the constraint reference points to)
/// </summary>
public Dictionary<DatabaseColumnRequest, DiscoveredColumn> ForeignKeyPairs { get; set; }
public Dictionary<DatabaseColumnRequest, DiscoveredColumn>? ForeignKeyPairs { get; set; }

/// <summary>
/// When creating a foreign key constraint (See <see cref="ForeignKeyPairs"/>) determines whether ON DELETE CASCADE should be set.
Expand All @@ -57,7 +57,7 @@ public sealed class CreateTableArgs(DiscoveredDatabase database, string tableNam
/// <summary>
/// The data to use to determine table schema and load into the newly created table (unless <see cref="CreateEmpty"/> is set).
/// </summary>
public DataTable DataTable { get; set; }
public DataTable? DataTable { get; set; }

/// <summary>
/// When creating the table, do not upload any rows supplied in <see cref="DataTable"/>
Expand All @@ -78,7 +78,7 @@ public sealed class CreateTableArgs(DiscoveredDatabase database, string tableNam
/// Populated after the table has been created (See <see cref="TableCreated"/>), list of the <see cref="Guesser"/> used to create the columns in the table.
/// <para>This will be null if no <see cref="DataTable"/> was provided when creating the table</para>
/// </summary>
public Dictionary<string, Guesser> ColumnCreationLogic { get; private set; }
public Dictionary<string, Guesser>? ColumnCreationLogic { get; private set; }

/// <summary>
/// Used to determine what how to parse untyped strings in <see cref="DataTable"/> (if building schema from data table).
Expand Down
1 change: 1 addition & 0 deletions FAnsiSql/Discovery/TypeTranslation/TypeTranslater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public abstract partial class TypeTranslater : ITypeTranslater
/// <summary>
///
/// </summary>
/// <param name="dateRegex"><see cref="DateRegex"/></param>
/// <param name="maxStringWidthBeforeMax"><see cref="MaxStringWidthBeforeMax"/></param>
/// <param name="stringWidthWhenNotSupplied"><see cref="StringWidthWhenNotSupplied"/></param>
protected TypeTranslater(Regex dateRegex, int maxStringWidthBeforeMax, int stringWidthWhenNotSupplied)
Expand Down
2 changes: 1 addition & 1 deletion FAnsiSql/FAnsi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</PackageReference>
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="Npgsql" Version="8.0.3" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.5.0" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.5.1" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions FAnsiSql/Implementations/MicrosoftSQL/MicrosoftSQLBulkCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private Exception AttemptLineByLineInsert(Exception e, SqlBulkCopy insert, DataT
/// <param name="newMessage"></param>
/// <param name="badMapping"></param>
/// <returns></returns>
private bool BcpColIdToString(SqlBulkCopy insert, SqlException? ex, out string? newMessage, out SqlBulkCopyColumnMapping? badMapping)
private static bool BcpColIdToString(SqlBulkCopy insert, SqlException? ex, out string? newMessage, out SqlBulkCopyColumnMapping? badMapping)
{
var match = ColumnLevelComplaint.Match(ex?.Message ?? "");
if (ex == null || !match.Success)
Expand Down Expand Up @@ -230,7 +230,7 @@ private static string ExceptionToListOfInnerMessages(Exception e, bool includeSt
}

if (e is ReflectionTypeLoadException reflectionTypeLoadException)
foreach (var loaderException in reflectionTypeLoadException.LoaderExceptions)
foreach (var loaderException in reflectionTypeLoadException.LoaderExceptions.OfType<Exception>())
{
message.AppendLine();
message.Append(ExceptionToListOfInnerMessages(loaderException, includeStackTrace));
Expand All @@ -239,7 +239,7 @@ private static string ExceptionToListOfInnerMessages(Exception e, bool includeSt
if (e.InnerException == null) return message.ToString();

message.AppendLine();
message.Append( ExceptionToListOfInnerMessages(e.InnerException, includeStackTrace));
message.Append(ExceptionToListOfInnerMessages(e.InnerException, includeStackTrace));
return message.ToString();
}

Expand Down
Loading

0 comments on commit d1282ef

Please sign in to comment.