Skip to content

Commit

Permalink
Clean up whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jas88 committed Aug 31, 2023
1 parent 4a3e4b0 commit 1c060fe
Show file tree
Hide file tree
Showing 37 changed files with 176 additions and 176 deletions.
2 changes: 1 addition & 1 deletion FAnsiSql/DatabaseType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum DatabaseType
MicrosoftSQLServer,

/// <summary>
/// My Sql database engine.
/// My Sql database engine.
/// </summary>
MySql,

Expand Down
14 changes: 7 additions & 7 deletions FAnsiSql/Discovery/BulkCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class BulkCopy:IBulkCopy
/// call <see cref="InvalidateTableSchema"/> to refresh this.
/// </summary>
protected DiscoveredColumn[] TargetTableColumns;

/// <summary>
/// When calling GetMapping if there are DataColumns in the input table that you are trying to bulk insert that are not matched
/// in the destination table then the default behaviour is to throw a KeyNotFoundException. Set this to false to ignore that
Expand All @@ -41,7 +41,7 @@ public abstract class BulkCopy:IBulkCopy

/// <inheritdoc/>
public DateTimeTypeDecider DateTimeDecider {get; protected set; }

/// <summary>
/// Begins a new bulk copy operation in which one or more data tables are uploaded to the <paramref name="targetTable"/>. The API entrypoint for this is
/// <see cref="DiscoveredTable.BeginBulkInsert(IManagedTransaction)"/>.
Expand Down Expand Up @@ -126,7 +126,7 @@ protected void ConvertStringTypesToHardTypes(DataTable dt)
decider = DateTimeDecider;
DateTimeDecider.GuessDateFormat(dt.Rows.Cast<DataRow>().Take(500).Select(r=>r[kvp.Key] as string));
}


foreach(DataRow dr in dt.Rows)
{
Expand Down Expand Up @@ -160,8 +160,8 @@ protected void ConvertStringTypesToHardTypes(DataTable dt)
}

/// <summary>
/// Returns a case insensitive mapping between columns in your DataTable that you are trying to upload and the columns that actually exist in the destination
/// table.
/// Returns a case insensitive mapping between columns in your DataTable that you are trying to upload and the columns that actually exist in the destination
/// table.
/// <para>This overload gives you a list of all unmatched destination columns, these should be given null/default automatically by your database API</para>
/// <para>Throws <exception cref="KeyNotFoundException"> if there are unmatched input columns unless <see cref="AllowUnmatchedInputColumns"/> is true.</exception></para>
/// </summary>
Expand Down Expand Up @@ -194,8 +194,8 @@ protected Dictionary<DataColumn, DiscoveredColumn> GetMapping(IEnumerable<DataCo
}

/// <summary>
/// Returns a case insensitive mapping between columns in your DataTable that you are trying to upload and the columns that actually exist in the destination
/// table.
/// Returns a case insensitive mapping between columns in your DataTable that you are trying to upload and the columns that actually exist in the destination
/// table.
/// <para>Throws <exception cref="KeyNotFoundException"> if there are unmatched input columns unless <see cref="AllowUnmatchedInputColumns"/> is true.</exception></para>
/// </summary>
/// <param name="inputColumns"></param>
Expand Down
4 changes: 2 additions & 2 deletions FAnsiSql/Discovery/DiscoveredDataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace FAnsi.Discovery;
/// </summary>
public class DiscoveredDataType
{
private readonly DiscoveredColumn Column;
private readonly DiscoveredColumn Column;

/// <summary>
/// The proprietary DBMS name for the datatype e.g. varchar2(100) for Oracle, datetime2 for Sql Server etc.
Expand Down Expand Up @@ -104,7 +104,7 @@ public void Resize(int newSize, IManagedTransaction managedTransaction = null)
}

/// <summary>
/// <para>Creates and runs an ALTER TABLE statement which will increase the size of a decimal column to support larger Precision/Scale values than it currently does.
/// <para>Creates and runs an ALTER TABLE statement which will increase the size of a decimal column to support larger Precision/Scale values than it currently does.
/// If you want decimal(4,2) then pass <paramref name="numberOfDigitsBeforeDecimalPoint"/>=2 and <paramref name="numberOfDigitsAfterDecimalPoint"/>=2</para>
///
/// <para>Throws <see cref="InvalidResizeException"/> if the column is not a decimal type or the new size is smaller than the current column size</para>
Expand Down
8 changes: 4 additions & 4 deletions FAnsiSql/Discovery/DiscoveredDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public IEnumerable<DiscoveredTableValuedFunction> DiscoverTableValuedFunctions(I
Helper.ListTableValuedFunctions(this, _querySyntaxHelper, managedConnection.Connection,
GetRuntimeName(), managedConnection.Transaction).ToArray();
}

/// <summary>
/// Returns the name of the database without any qualifiers
/// </summary>
Expand All @@ -82,7 +82,7 @@ public string GetRuntimeName()
{
return _querySyntaxHelper.GetRuntimeName(_database);
}

/// <summary>
/// Returns the wrapped e.g. "[MyDatabase]" name of the database including escaping e.g. if you wanted to name a database "][nquisitor" (which would return "[]][nquisitor]").
/// </summary>
Expand Down Expand Up @@ -250,7 +250,7 @@ public DiscoveredTable CreateTable(CreateTableArgs args)
}

/// <summary>
/// Creates a table in the database big enough to store the supplied DataTable with appropriate types.
/// Creates a table in the database big enough to store the supplied DataTable with appropriate types.
/// </summary>
/// <param name="typeDictionary">The computers used to determine column types</param>
/// <param name="tableName"></param>
Expand All @@ -275,7 +275,7 @@ public DiscoveredTable CreateTable(out Dictionary<string, Guesser> typeDictionar

return table;
}


/// <summary>
/// Creates a new schema within the database if the DBMS supports it (Sql Server does, MySql doesn't) and it does not already exist. Schema
Expand Down
16 changes: 8 additions & 8 deletions FAnsiSql/Discovery/DiscoveredDatabaseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ public DiscoveredTable CreateTable(CreateTableArgs args)

//Type requested is a proper FAnsi type (e.g. string, at least 5 long)
var request = overriding.TypeRequested;

if(request == null)
if(!string.IsNullOrWhiteSpace(overriding.ExplicitDbType))
{
//Type is for an explicit SQL Type e.g. varchar(5)

//Translate the sql type to a FAnsi type definition
//Translate the sql type to a FAnsi type definition
var tt = args.Database.Server.GetQuerySyntaxHelper().TypeTranslater;

request = tt.GetDataTypeRequestForSQLDBType(overriding.ExplicitDbType);

}
else
throw new Exception(string.Format(FAnsiStrings.DiscoveredDatabaseHelper_CreateTable_DatabaseColumnRequestMustHaveEitherTypeRequestedOrExplicitDbType, column));
Expand All @@ -84,15 +84,15 @@ public DiscoveredTable CreateTable(CreateTableArgs args)
//no, work out the column definition using a guesser
var guesser = GetGuesser(column);
guesser.Culture = args.Culture;

CopySettings(guesser,args);

guesser.AdjustToCompensateForValues(column);

//if DoNotRetype is set on the column adjust the requested CSharpType to be the original type
if (column.GetDoNotReType())
guesser.Guess.CSharpType = column.DataType;

typeDictionary.Add(column.ColumnName,guesser);

columns.Add(new DatabaseColumnRequest(column.ColumnName, guesser.Guess, column.AllowDBNull) { IsPrimaryKey = args.DataTable.PrimaryKey.Contains(column)});
Expand Down Expand Up @@ -202,7 +202,7 @@ public virtual string GetCreateTableSql(DiscoveredDatabase database, string tabl
foreach (var col in columns)
{
var datatype = col.GetSQLDbType(syntaxHelper.TypeTranslater);

//add the column name and accompanying datatype
bodySql.AppendLine($"{GetCreateTableSqlLineForColumn(col, datatype, syntaxHelper)},");
}
Expand Down Expand Up @@ -278,7 +278,7 @@ private string MakeSensibleConstraintName(string prefix, string tableName)

return $"{prefix}{constraintName}";
}

public void ExecuteBatchNonQuery(string sql, DbConnection conn, DbTransaction transaction = null, int timeout = 30)
{
ExecuteBatchNonQuery(sql, conn, transaction, out _, timeout);
Expand Down
10 changes: 5 additions & 5 deletions FAnsiSql/Discovery/DiscoveredServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private DbParameter GetParameter(string parameterName)
}

/// <summary>
/// Returns a new <see cref="DbParameter"/> of the correct <see cref="DatabaseType"/> of the server. Also adds it
/// Returns a new <see cref="DbParameter"/> of the correct <see cref="DatabaseType"/> of the server. Also adds it
/// to the <see cref="DbCommand.Parameters"/> of <paramref name="command"/> and sets it's <paramref name="valueForParameter"/>
/// </summary>
/// <param name="parameterName"></param>
Expand Down Expand Up @@ -305,10 +305,10 @@ public DiscoveredDatabase GetCurrentDatabase()
//no (e.g. Oracle or no default database specified in connection string)
return _currentDatabase; //yes use that one
}

/// <summary>
/// Edits the connection string (See <see cref="Builder"/>) to allow async operations. Depending on DBMS this may have
/// no effect (e.g. Sql Server needs AsynchronousProcessing and MultipleActiveResultSets but Oracle / MySql do not need
/// Edits the connection string (See <see cref="Builder"/>) to allow async operations. Depending on DBMS this may have
/// no effect (e.g. Sql Server needs AsynchronousProcessing and MultipleActiveResultSets but Oracle / MySql do not need
/// any special keywords)
/// </summary>
public void EnableAsync()
Expand Down Expand Up @@ -391,7 +391,7 @@ public IQuerySyntaxHelper GetQuerySyntaxHelper()
{
return Helper.GetQuerySyntaxHelper();
}

/// <summary>
/// Return key value pairs which describe attributes of the server e.g. version, available drive space etc
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions FAnsiSql/Discovery/DiscoveredServerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void AddConnectionStringKeyword(DatabaseType databaseType, string

ConnectionStringKeywordAccumulators[databaseType].AddOrUpdateKeyword(keyword,value,priority);
}

/// <include file='../../CommonMethods.doc.xml' path='Methods/Method[@name="GetCommand"]'/>
public abstract DbCommand GetCommand(string s, DbConnection con, DbTransaction transaction = null);

Expand All @@ -43,7 +43,7 @@ public static void AddConnectionStringKeyword(DatabaseType databaseType, string

/// <include file='../../CommonMethods.doc.xml' path='Methods/Method[@name="GetParameter"]'/>
public abstract DbParameter GetParameter(string parameterName);

public abstract DbConnection GetConnection(DbConnectionStringBuilder builder);

public DbConnectionStringBuilder GetConnectionStringBuilder(string connectionString)
Expand All @@ -53,7 +53,7 @@ public DbConnectionStringBuilder GetConnectionStringBuilder(string connectionStr

return builder;
}

/// <inheritdoc/>
public DbConnectionStringBuilder GetConnectionStringBuilder(string server, string database, string username, string password)
{
Expand All @@ -76,8 +76,8 @@ protected virtual void EnforceKeywords(DbConnectionStringBuilder builder)
}
protected abstract DbConnectionStringBuilder GetConnectionStringBuilderImpl(string connectionString, string database, string username, string password);
protected abstract DbConnectionStringBuilder GetConnectionStringBuilderImpl(string connectionString);



protected abstract string ServerKeyName { get; }
protected abstract string DatabaseKeyName { get; }
Expand Down
16 changes: 8 additions & 8 deletions FAnsiSql/Discovery/DiscoveredTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public DiscoveredTable(DiscoveredDatabase database, string table, IQuerySyntaxHe

QuerySyntaxHelper.ValidateTableName(_table);
}

/// <summary>
/// <para>Checks that the <see cref="Database"/> exists then lists the tables in the database to confirm this table exists on the server</para>
/// </summary>
Expand Down Expand Up @@ -101,7 +101,7 @@ public virtual string GetFullyQualifiedName()
{
return QuerySyntaxHelper.EnsureFullyQualified(Database.GetRuntimeName(),Schema, GetRuntimeName());
}

/// <summary>
/// Returns the wrapped e.g. "[MyTbl]" name of the table including escaping e.g. if you wanted to name a table "][nquisitor" (which would return "[]][nquisitor]"). Use <see cref="GetFullyQualifiedName()"/> to return the full name including table/database/schema.
/// </summary>
Expand Down Expand Up @@ -142,7 +142,7 @@ public IQuerySyntaxHelper GetQuerySyntaxHelper()

/// <summary>
/// Returns from <see cref="DiscoverColumns"/> the <paramref name="specificColumnName"/> on the server. This is not not case sensitive. Requires
/// connecting to the database.
/// connecting to the database.
/// </summary>
/// <param name="specificColumnName">The column you want to find</param>
/// <param name="transaction">Optional - if set the connection to list tables will be sent on the connection on which the current
Expand Down Expand Up @@ -198,9 +198,9 @@ public DataTable GetDataTable(DatabaseOperationArgs args,int topX = int.MaxValue

return dt;
}

/// <summary>
/// Drops (deletes) the table from the database. This is irreversible unless you have a database backup.
/// Drops (deletes) the table from the database. This is irreversible unless you have a database backup.
/// </summary>
public virtual void Drop()
{
Expand All @@ -223,7 +223,7 @@ public int GetRowCount(DatabaseOperationArgs args)
{
return Helper.GetRowCount(args, this);
}

/// <summary>
/// Returns true if there are no rows in the table
/// </summary>
Expand Down Expand Up @@ -294,7 +294,7 @@ public void DropColumn(DiscoveredColumn column)
using var connection = Database.Server.GetManagedConnection();
Helper.DropColumn(connection.Connection, column);
}

/// <summary>
/// Creates a new object for bulk inserting records into the table. You should use a using block since <see cref="IBulkCopy"/> is <see cref="IDisposable"/>.
/// Depending on implementation, records may not be committed to the server until the <see cref="IBulkCopy"/> is disposed.
Expand Down Expand Up @@ -411,7 +411,7 @@ public void CreatePrimaryKey(IManagedTransaction transaction ,CancellationToken
}, this, discoverColumns);
}


public void CreatePrimaryKey(DatabaseOperationArgs args, params DiscoveredColumn[] discoverColumns)
{
Helper.CreatePrimaryKey(args,this, discoverColumns);
Expand Down
2 changes: 1 addition & 1 deletion FAnsiSql/Discovery/DiscoveredTableHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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 IDiscoveredColumnHelper GetColumnHelper();
public virtual void DropTable(DbConnection connection, DiscoveredTable tableToDrop)
{
Expand Down
4 changes: 2 additions & 2 deletions FAnsiSql/Discovery/DiscoveredTableValuedFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace FAnsi.Discovery;
public class DiscoveredTableValuedFunction : DiscoveredTable
{
private readonly string _functionName;

//constructor
public DiscoveredTableValuedFunction(DiscoveredDatabase database, string functionName,
IQuerySyntaxHelper querySyntaxHelper, string schema = null) : base(database, functionName, querySyntaxHelper,
Expand All @@ -36,7 +36,7 @@ public override string GetFullyQualifiedName()
//Note that we do not give the parameters values, the client must decide appropriate values and put them in correspondingly named variables
return $"{Database.GetRuntimeName()}..{GetRuntimeName()}({parameters})";
}

public override string ToString() => _functionName;

public override void Drop()
Expand Down
4 changes: 2 additions & 2 deletions FAnsiSql/Discovery/IDiscoveredDatabaseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface IDiscoveredDatabaseHelper
Dictionary<string, string> DescribeDatabase(DbConnectionStringBuilder builder, string database);

DiscoveredTable CreateTable(CreateTableArgs args);

string GetCreateTableSql(DiscoveredDatabase database, string tableName, DatabaseColumnRequest[] columns, Dictionary<DatabaseColumnRequest, DiscoveredColumn> foreignKeyPairs, bool cascadeDelete,string schema = null);

/// <summary>
Expand All @@ -47,7 +47,7 @@ string GetForeignKeyConstraintSql(string foreignTable, IQuerySyntaxHelper syntax

DirectoryInfo Detach(DiscoveredDatabase database);
void CreateBackup(DiscoveredDatabase discoveredDatabase, string backupName);

/// <summary>
/// Gets a sensible name for a foreign key constraint between the two tables
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions FAnsiSql/Discovery/IDiscoveredServerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public interface IDiscoveredServerHelper
DbConnection GetConnection(DbConnectionStringBuilder builder);

DbConnectionStringBuilder GetConnectionStringBuilder(string connectionString);

/// <summary>
/// Returns a new connection string builder with the supplied parameters. Note that if a concept is not supported in the
/// Returns a new connection string builder with the supplied parameters. Note that if a concept is not supported in the
/// <see cref="DbConnectionStringBuilder"/> implementation then the value will not appear in the connection string (e.g. Oracle
/// does not support specifying a <paramref name="database"/> to connect to).
/// </summary>
Expand Down Expand Up @@ -54,7 +54,7 @@ public interface IDiscoveredServerHelper
DatabaseType DatabaseType { get; }
Dictionary<string, string> DescribeServer(DbConnectionStringBuilder builder);
bool RespondsWithinTime(DbConnectionStringBuilder builder, int timeoutInSeconds, out Exception exception);

string GetExplicitUsernameIfAny(DbConnectionStringBuilder builder);
string GetExplicitPasswordIfAny(DbConnectionStringBuilder builder);
Version GetVersion(DiscoveredServer server);
Expand Down
Loading

0 comments on commit 1c060fe

Please sign in to comment.