[Tdbc] Fix Sqlite update hook (#5251)
authorilho159kim <ilho159.kim@samsung.com>
Thu, 11 May 2023 06:11:42 +0000 (15:11 +0900)
committerGitHub <noreply@github.com>
Thu, 11 May 2023 06:11:42 +0000 (15:11 +0900)
If the delete statement is executed, the record can't be returned
because the value for the rowid doesn't exist in the database
Therefore, in the case of delete, the record is returned to null

Signed-off-by: ilho kim <ilho159.kim@samsung.com>
Co-authored-by: pjh9216 <jh9216.park@samsung.com>
src/Tizen.Data.Tdbc.Driver.Sqlite/Tizen.Data.Tdbc.Driver.Sqlite/Connection.cs

index 0668970..4381aca 100644 (file)
@@ -62,7 +62,7 @@ namespace Tizen.Data.Tdbc.Driver.Sqlite
         {
             Open(new Uri(openString));
         }
-        
+
         public void Close()
         {
             if (_opened)
@@ -92,7 +92,7 @@ namespace Tizen.Data.Tdbc.Driver.Sqlite
             Sql sql = new Sql(string.Format("SELECT * from {0} WHERE rowid = {1}", table_name, rowid));
             using (IStatement stmt = CreateStatement())
             {
-                IRecord record = stmt.ExecuteQuery(sql).FirstOrDefault();
+                IRecord record = (operationType != OperationType.Delete ? stmt.ExecuteQuery(sql).FirstOrDefault() : null);
                 RecordChangedEventArgs ev = new RecordChangedEventArgs(operationType, db_name, table_name, record);
                 _recordChanged?.Invoke(this, ev);
             }