Commit b82c2750 authored by Dave Peters's avatar Dave Peters

Fixed issue DapperTable

This fixes a bug found in CS 51509960 where the following sequence would
result in an InvalidOperationException being thrown due to an attempt to
access a disposed of DataReader:

- Perform a dynamic query that yields no results
- Add data to the source of that query
- Perform a the same query again
parent 8b405c70
......@@ -1524,7 +1524,7 @@ public object SetValue(string key, object value)
string[] names = new string[effectiveFieldCount];
for (int i = 0; i < effectiveFieldCount; i++)
{
names[i] = reader.GetName(i + startBound);
names[i] = r.GetName(i + startBound);
}
table = new DapperTable(names);
}
......
......@@ -2253,6 +2253,24 @@ public void Open()
}
}
public void TestDapperTableMetadataRetrieval()
{
// Test for a bug found in CS 51509960 where the following sequence would result in an InvalidOperationException being
// thrown due to an attempt to access a disposed of DataReader:
//
// - Perform a dynamic query that yields no results
// - Add data to the source of that query
// - Perform a the same query again
connection.Execute("CREATE TABLE #sut (value varchar(10) NOT NULL PRIMARY KEY)");
connection.Query("SELECT value FROM #sut").IsSequenceEqualTo(Enumerable.Empty<dynamic>());
connection.Execute("INSERT INTO #sut (value) VALUES ('test')").IsEqualTo(1);
var result = connection.Query("SELECT value FROM #sut");
var first = result.First();
((string)first.value).IsEqualTo("test");
}
#if POSTGRESQL
class Cat
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment