Skip to content

Commit

Permalink
Revert "Return empty DataTable from GetSchemaTable. (#419)" (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra authored Aug 19, 2020
1 parent 0c80751 commit 9ce5e66
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 @@ -1479,7 +1479,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 @@ -37,6 +37,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 @@ -65,25 +66,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 9ce5e66

Please sign in to comment.