Index: Doc/Extra/Provider/version.html
==================================================================
--- Doc/Extra/Provider/version.html
+++ Doc/Extra/Provider/version.html
@@ -47,10 +47,11 @@
- Updated to SQLite 3.8.4.1.
- Update the list of keywords returned by SQLiteConnection.GetSchema("ReservedWords"). ** Potentially Incompatible Change **
- Raise the static SQLiteConnection.Changed event when any SQLiteCommand or SQLiteDataReader object is closed or disposed.
- Add the SQLiteDataReader.StepCount property to return the number of rows seen so far.
+ - Add StickyHasRows connection flag to cause the SQLiteDataReader.HasRows property to return non-zero if there were ever any rows in the associated result sets.
- When the TraceWarning connection flag is set, issue warnings about possibly malformed UNC paths. Pursuant to [283344397b].
- Convert the primary NuGet package, "System.Data.SQLite", into a meta-package.
- Enhancements to the NuGet packages, including the new "modular" packages.
1.0.91.0 - February 12, 2014
Index: System.Data.SQLite/SQLiteBase.cs
==================================================================
--- System.Data.SQLite/SQLiteBase.cs
+++ System.Data.SQLite/SQLiteBase.cs
@@ -1032,10 +1032,17 @@
/// associated values. Therefore, use of this flag
/// is not recommended.
///
NoGlobalTypes = 0x200000,
+ ///
+ /// When the property is used, it
+ /// should return non-zero if there were ever any rows in the associated
+ /// result sets.
+ ///
+ StickyHasRows = 0x400000,
+
///
/// When binding parameter values or returning column values, always
/// treat them as though they were plain text (i.e. no numeric,
/// date/time, or other conversions should be attempted).
///
Index: System.Data.SQLite/SQLiteDataReader.cs
==================================================================
--- System.Data.SQLite/SQLiteDataReader.cs
+++ System.Data.SQLite/SQLiteDataReader.cs
@@ -44,15 +44,15 @@
///
private int _rowsAffected;
///
/// Count of fields (columns) in the row-returning statement currently being processed
///
- private int _fieldCount;
- ///
- /// The number of calls to Step() that have returned true (i.e. the number of rows that
- /// have been read in the current result set).
- ///
+ private int _fieldCount;
+ ///
+ /// The number of calls to Step() that have returned true (i.e. the number of rows that
+ /// have been read in the current result set).
+ ///
private int _stepCount;
///
/// Maps the field (column) names to their corresponding indexes within the results.
///
private Dictionary _fieldIndexes;
@@ -312,24 +312,24 @@
if (_keyInfo == null)
return _fieldCount;
return _fieldCount + _keyInfo.Count;
}
- }
-
- ///
- /// Returns the number of rows seen so far in the current result set.
- ///
- public int StepCount
- {
- get
- {
- CheckDisposed();
- CheckClosed();
-
- return _stepCount;
- }
+ }
+
+ ///
+ /// Returns the number of rows seen so far in the current result set.
+ ///
+ public int StepCount
+ {
+ get
+ {
+ CheckDisposed();
+ CheckClosed();
+
+ return _stepCount;
+ }
}
///
/// Returns the number of visible fields in the current resultset
///
@@ -1197,10 +1197,28 @@
{
get
{
CheckDisposed();
CheckClosed();
+
+ //
+ // NOTE: If the "sticky" flag has been set, use the new behavior,
+ // which returns non-zero if there were ever any rows in
+ // the associated result sets. Generally, this flag is only
+ // useful when it is necessary to retain compatibility with
+ // other ADO.NET providers that use these same semantics for
+ // the HasRows property.
+ //
+ if ((GetFlags(this) & SQLiteConnectionFlags.StickyHasRows) == SQLiteConnectionFlags.StickyHasRows)
+ return ((_readingState != 1) || (_stepCount > 0));
+
+ //
+ // NOTE: This is the default behavior. It returns non-zero only if
+ // more rows are available (i.e. a call to the Read method is
+ // expected to succeed). Prior to the introduction of the
+ // "sticky" flag, this is how this property has always worked.
+ //
return (_readingState != 1);
}
}
///
@@ -1253,13 +1271,13 @@
{
for (; ; )
{
stmt = _command.GetStatement(_activeStatementIndex + 1);
if (stmt == null) break;
- _activeStatementIndex++;
-
- if (!schemaOnly && stmt._sql.Step(stmt)) _stepCount++;
+ _activeStatementIndex++;
+
+ if (!schemaOnly && stmt._sql.Step(stmt)) _stepCount++;
if (stmt._sql.ColumnCount(stmt) == 0)
{
if (_rowsAffected == -1) _rowsAffected = 0;
int changes = 0;
if (stmt.TryGetChanges(ref changes))
@@ -1290,11 +1308,11 @@
// If the statement is not a select statement or we're not retrieving schema only, then perform the initial step
if (!schemaOnly || (fieldCount == 0))
{
if (!schemaOnly && stmt._sql.Step(stmt))
- {
+ {
_stepCount++;
_readingState = -1;
}
else if (fieldCount == 0) // No rows returned, if fieldCount is zero, skip to the next statement
{
@@ -1443,12 +1461,12 @@
else if (_readingState == 0) // Actively reading rows
{
// Don't read a new row if the command behavior dictates SingleRow. We've already read the first row.
if ((_commandBehavior & CommandBehavior.SingleRow) == 0)
{
- if (_activeStatement._sql.Step(_activeStatement) == true)
- {
+ if (_activeStatement._sql.Step(_activeStatement) == true)
+ {
_stepCount++;
if (_keyInfo != null)
_keyInfo.Reset();
Index: Tests/basic.eagle
==================================================================
--- Tests/basic.eagle
+++ Tests/basic.eagle
@@ -3011,12 +3011,67 @@
True True False False True False False True 1 True 1 True 0 False False False\
True False False False False False False 1 True 1 True 1 True}}
###############################################################################
-runTest {test data-1.64 {SQLiteDataReader StepCount property} -setup {
- setupDb [set fileName data-1.64.db]
+runTest {test data-1.64 {SQLiteDataReader sticky HasRows property} -setup {
+ setupDb [set fileName data-1.64.db] "" "" "" StickyHasRows
+} -body {
+ sql execute $db {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(x);
+ INSERT INTO t2 (x) VALUES(1);
+ CREATE TABLE t3(x);
+ INSERT INTO t3 (x) VALUES(1);
+ INSERT INTO t3 (x) VALUES(2);
+ }
+
+ set reader(1) [sql execute -execute reader -format datareader -alias \
+ $db "SELECT * FROM t1;"]
+
+ set reader(2) [sql execute -execute reader -format datareader -alias \
+ $db "SELECT * FROM t2;"]
+
+ set reader(3) [sql execute -execute reader -format datareader -alias \
+ $db "SELECT * FROM t3;"]
+
+ set noRow "*: No current row*"
+
+ list [$reader(1) HasRows] [$reader(2) HasRows] [$reader(3) HasRows] \
+ [$reader(1) Read] [$reader(2) Read] [$reader(3) Read] \
+ [$reader(1) HasRows] [$reader(2) HasRows] [$reader(3) HasRows] \
+ [catch {$reader(1) Item x} error] [string match $noRow $error] \
+ [catch {$reader(2) Item x} error] [string match $noRow $error] \
+ [catch {$reader(3) Item x} error] [string match $noRow $error] \
+ [$reader(1) HasRows] [$reader(2) HasRows] [$reader(3) HasRows] \
+ [$reader(1) Read] [$reader(2) Read] [$reader(3) Read] \
+ [$reader(1) HasRows] [$reader(2) HasRows] [$reader(3) HasRows] \
+ [catch {$reader(1) Item x} error] [string match $noRow $error] \
+ [catch {$reader(2) Item x} error] [string match $noRow $error] \
+ [catch {$reader(3) Item x} error] [string match $noRow $error] \
+ [$reader(1) HasRows] [$reader(2) HasRows] [$reader(3) HasRows] \
+ [$reader(1) Read] [$reader(2) Read] [$reader(3) Read] \
+ [$reader(1) HasRows] [$reader(2) HasRows] [$reader(3) HasRows] \
+ [catch {$reader(1) Item x} error] [string match $noRow $error] \
+ [catch {$reader(2) Item x} error] [string match $noRow $error] \
+ [catch {$reader(3) Item x} error] [string match $noRow $error]
+} -cleanup {
+ unset -nocomplain reader
+
+ cleanupDb $fileName
+
+ unset -nocomplain error noRow db fileName
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
+{False True True False True True False True True 1 True 0 False 0 False False\
+True True False False True False True True 1 True 1 True 0 False False True\
+True False False False False True True 1 True 1 True 1 True}}
+
+###############################################################################
+
+runTest {test data-1.65 {SQLiteDataReader StepCount property} -setup {
+ setupDb [set fileName data-1.65.db]
} -body {
sql execute $db {
CREATE TABLE t1(x);
CREATE TABLE t2(x);
INSERT INTO t2 (x) VALUES(1);
Index: readme.htm
==================================================================
--- readme.htm
+++ readme.htm
@@ -214,10 +214,11 @@
- Updated to SQLite 3.8.4.1.
- Update the list of keywords returned by SQLiteConnection.GetSchema("ReservedWords"). ** Potentially Incompatible Change **
- Raise the static SQLiteConnection.Changed event when any SQLiteCommand or SQLiteDataReader object is closed or disposed.
- Add the SQLiteDataReader.StepCount property to return the number of rows seen so far.
+ - Add StickyHasRows connection flag to cause the SQLiteDataReader.HasRows property to return non-zero if there were ever any rows in the associated result sets.
- When the TraceWarning connection flag is set, issue warnings about possibly malformed UNC paths. Pursuant to [283344397b].
- Convert the primary NuGet package, "System.Data.SQLite", into a meta-package.
- Enhancements to the NuGet packages, including the new "modular" packages.
Index: www/news.wiki
==================================================================
--- www/news.wiki
+++ www/news.wiki
@@ -8,10 +8,11 @@
- Updated to SQLite 3.8.4.1.
- Update the list of keywords returned by SQLiteConnection.GetSchema("ReservedWords"). ** Potentially Incompatible Change **
- Raise the static SQLiteConnection.Changed event when any SQLiteCommand or SQLiteDataReader object is closed or disposed.
- Add the SQLiteDataReader.StepCount property to return the number of rows seen so far.
+ - Add StickyHasRows connection flag to cause the SQLiteDataReader.HasRows property to return non-zero if there were ever any rows in the associated result sets.
- When the TraceWarning connection flag is set, issue warnings about possibly malformed UNC paths. Pursuant to [283344397b].
- Convert the primary NuGet package, "System.Data.SQLite", into a meta-package.
- Enhancements to the NuGet packages, including the new "modular" packages.