Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,9 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlMetaDataFactory.cs">
<Link>Microsoft\Data\SqlClient\SqlMetaDataFactory.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlMetaDataFactory.DataTypes.cs">
<Link>Microsoft\Data\SqlClient\SqlMetaDataFactory.DataTypes.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlNotificationEventArgs.cs">
<Link>Microsoft\Data\SqlClient\SqlNotificationEventArgs.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,9 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlMetaDataFactory.cs">
<Link>Microsoft\Data\SqlClient\SqlMetaDataFactory.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlMetaDataFactory.DataTypes.cs">
<Link>Microsoft\Data\SqlClient\SqlMetaDataFactory.DataTypes.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlNotificationEventArgs.cs">
<Link>Microsoft\Data\SqlClient\SqlNotificationEventArgs.cs</Link>
</Compile>
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there existing unit tests for this functionality that are now testing this new file? Or do we need new tests for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are existing unit tests which prove that the process of building the schema dataset completes successfully, and there's a new (somewhat basic) unit test which proves that we've not missed any types from the original XML file.

The data which we add in this new file shouldn't change (barring new data types) so I've not added an automatic test to verify it field-by-field, I just performed a manual one-off check of the resultant DataTypes table against the original XML file.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Microsoft.Data.SqlClient
{
internal sealed class SqlMetaDataFactory : IDisposable
internal sealed partial class SqlMetaDataFactory : IDisposable
{
// Well-known column names
private const string CollectionNameKey = "CollectionName";
Expand Down Expand Up @@ -689,6 +689,9 @@ private DataSet LoadDataSetFromXml(Stream XmlStream)
{
Locale = CultureInfo.InvariantCulture
};

LoadDataTypesDataTables(metaDataCollectionsDataSet);

XmlReaderSettings settings = new()
{
XmlResolver = null,
Expand Down Expand Up @@ -738,9 +741,6 @@ private DataSet LoadDataSetFromXml(Stream XmlStream)
dataTable = CreateDataSourceInformationDataTable();
rowFixup = FixUpDataSourceInformationRow;
break;
case "DataTypesTable":
dataTable = CreateDataTypesDataTable();
break;
case "ReservedWordsTable":
dataTable = CreateReservedWordsDataTable();
break;
Expand Down Expand Up @@ -874,38 +874,6 @@ private static DataTable CreateDataSourceInformationDataTable()
}
};

private static DataTable CreateDataTypesDataTable()
=> new(DbMetaDataCollectionNames.DataTypes)
{
Columns =
{
new DataColumn(DbMetaDataColumnNames.TypeName, typeof(string)),
new DataColumn(DbMetaDataColumnNames.ProviderDbType, typeof(int)),
new DataColumn(DbMetaDataColumnNames.ColumnSize, typeof(long)),
new DataColumn(DbMetaDataColumnNames.CreateFormat, typeof(string)),
new DataColumn(DbMetaDataColumnNames.CreateParameters, typeof(string)),
new DataColumn(DbMetaDataColumnNames.DataType, typeof(string)),
new DataColumn(DbMetaDataColumnNames.IsAutoIncrementable, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.IsBestMatch, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.IsCaseSensitive, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.IsFixedLength, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.IsFixedPrecisionScale, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.IsLong, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.IsNullable, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.IsSearchable, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.IsSearchableWithLike, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.IsUnsigned, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.MaximumScale, typeof(short)),
new DataColumn(DbMetaDataColumnNames.MinimumScale, typeof(short)),
new DataColumn(DbMetaDataColumnNames.IsConcurrencyType, typeof(bool)),
new DataColumn(MaximumVersionKey, typeof(string)),
new DataColumn(MinimumVersionKey, typeof(string)),
new DataColumn(DbMetaDataColumnNames.IsLiteralSupported, typeof(bool)),
new DataColumn(DbMetaDataColumnNames.LiteralPrefix, typeof(string)),
new DataColumn(DbMetaDataColumnNames.LiteralSuffix, typeof(string))
}
};

private static DataTable CreateReservedWordsDataTable()
=> new(DbMetaDataCollectionNames.ReservedWords)
{
Expand Down
Loading
Loading