Index: System.Data.SQLite/SQLiteDataReader.cs ================================================================== --- System.Data.SQLite/SQLiteDataReader.cs +++ System.Data.SQLite/SQLiteDataReader.cs @@ -517,17 +517,18 @@ VerifyForGet(); if (_keyInfo == null) return null; - int iRowId = _keyInfo.GetRowIdIndex( - GetDatabaseName(i), GetTableName(i)); + string databaseName = GetDatabaseName(i); + string tableName = GetTableName(i); + int iRowId = _keyInfo.GetRowIdIndex(databaseName, tableName); - if (iRowId == -1) - return null; + if (iRowId != -1) + return GetInt64(iRowId); - return GetInt64(iRowId); + return _keyInfo.GetRowId(databaseName, tableName); } /// /// Retrieves the column as a object. /// This will not work for tables that were created WITHOUT ROWID Index: System.Data.SQLite/SQLiteKeyReader.cs ================================================================== --- System.Data.SQLite/SQLiteKeyReader.cs +++ System.Data.SQLite/SQLiteKeyReader.cs @@ -363,10 +363,37 @@ } } return -1; } + + /////////////////////////////////////////////////////////////////////////////////////////////// + + internal long? GetRowId( + string databaseName, + string tableName + ) + { + if ((_keyInfo != null) && + (databaseName != null) && + (tableName != null)) + { + for (int i = 0; i < _keyInfo.Length; i++) + { + if (_keyInfo[i].databaseName == databaseName && + _keyInfo[i].tableName == tableName) + { + long rowid = _stmt._sql.GetRowIdForCursor(_stmt, _keyInfo[i].cursor); + + if (rowid != 0) + return rowid; + } + } + } + + return null; + } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable Members public void Dispose() Index: Tests/basic.eagle ================================================================== --- Tests/basic.eagle +++ Tests/basic.eagle @@ -4621,10 +4621,76 @@ [getOtherCount Method_GetCachedXmlConfigFileName] >= 2} } -cleanup { moveSystemDataSQLiteDllConfig true } -constraints {eagle command.object monoBug28 System.Data.SQLite\ buildConfiguration.Debug} -result {True}} + +############################################################################### + +runTest {test data-1.89 {using SQLiteBlob without rowid PK index} -setup { + setupDb [set fileName data-1.89.db] +} -body { + sql execute $db { + CREATE TABLE t1 (x GUID UNIQUE NOT NULL, y BLOB NOT NULL); + INSERT INTO t1 (x, y) VALUES( + '12345678-0000-0000-0000-000000000000', + X'010203040506070809' + ); + INSERT INTO t1 (x, y) VALUES( + '12345679-0000-0000-0000-000000000000', + X'0102030405060708090A0B0C0D0E0F101113' + ); + } + + set sql(1) { \ + SELECT rowid, y FROM t1 \ + WHERE x = '12345678-0000-0000-0000-000000000000'; \ + } + + set sql(2) { \ + SELECT rowid, y FROM t1 \ + WHERE x = '12345679-0000-0000-0000-000000000000'; \ + } + + set dataReader [sql execute -execute reader -format datareader \ + -behavior +KeyInfo -alias $db $sql(1)] + + while {[$dataReader Read]} { + set blob [object invoke -alias \ + System.Data.SQLite.SQLiteBlob Create $dataReader 1 true] + + lappend result [$blob GetCount] + + $blob Close + } + + $dataReader Close; unset dataReader + + set dataReader [sql execute -execute reader -format datareader \ + -behavior +KeyInfo -alias $db $sql(2)] + + while {[$dataReader Read]} { + set blob [object invoke -alias \ + System.Data.SQLite.SQLiteBlob Create $dataReader 1 true] + + lappend result [$blob GetCount] + + $blob Close + } + + $dataReader Close; unset dataReader + + set result +} -cleanup { + unset -nocomplain blob + unset -nocomplain dataReader + + cleanupDb $fileName + + unset -nocomplain result sql db fileName +} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\ +System.Data.SQLite} -result {9 18}} ############################################################################### reportSQLiteResources $test_channel