Skip to content

Commit

Permalink
Revert "Return empty DataTable from GetSchemaTable. (dotnet#419)"
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Aug 18, 2020
1 parent dbbcde8 commit 0dd6b0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ public override DataTable GetSchemaTable()
Debug.Assert(null != _metaData.schemaTable, "No schema information yet!");
}
}
return _metaData?.schemaTable ?? new DataTable();
return _metaData?.schemaTable;
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1679,12 +1679,17 @@ override public DataTable GetSchemaTable()
{
if (null != this.MetaData)
{

_metaData.schemaTable = BuildSchemaTable();
Debug.Assert(null != _metaData.schemaTable, "No schema information yet!");
// filter table?
}
}
return _metaData?.schemaTable ?? new DataTable();
if (null != _metaData)
{
return _metaData.schemaTable;
}
return null;
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static void LoadReaderIntoDataTableToTestGetSchemaTable()
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static void MultiQuerySchema()
{
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(DataTestUtility.TCPConnectionString);
using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString))
{
connection.Open();
Expand Down Expand Up @@ -66,25 +67,7 @@ public static void MultiQuerySchema()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static void GetSchemaTable_returns_null_when_no_resultset()
{
using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString))
{
connection.Open();

using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = "SELECT 1";
using (SqlDataReader reader = command.ExecuteReader())
{
reader.NextResult();
Assert.NotNull(reader.GetSchemaTable());
}
}
}
}

// Checks for the IsColumnSet bit in the GetSchemaTable for Sparse columns
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static void CheckSparseColumnBit()
Expand Down

0 comments on commit 0dd6b0c

Please sign in to comment.