@@ -1648,8 +1648,12 @@ mod tests {
16481648 . await
16491649 . unwrap ( ) ;
16501650
1651- let before = query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1652- let before_count = total_rows ( & before) ;
1651+ let before = query_all (
1652+ & ctx,
1653+ "SELECT product_id FROM products WHERE product_id = 'PROD_DEL'" ,
1654+ )
1655+ . await ;
1656+ assert_eq ! ( total_rows( & before) , 1 ) ;
16531657
16541658 ctx. sql ( "DELETE FROM products WHERE product_id = 'PROD_DEL'" )
16551659 . await
@@ -1658,8 +1662,12 @@ mod tests {
16581662 . await
16591663 . expect ( "execute delete" ) ;
16601664
1661- let after = query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1662- assert_eq ! ( total_rows( & after) , before_count - 1 ) ;
1665+ let after = query_all (
1666+ & ctx,
1667+ "SELECT product_id FROM products WHERE product_id = 'PROD_DEL'" ,
1668+ )
1669+ . await ;
1670+ assert_eq ! ( total_rows( & after) , 0 ) ;
16631671 }
16641672
16651673 #[ tokio:: test]
@@ -1668,8 +1676,13 @@ mod tests {
16681676 let mut ctx = SessionContext :: new ( ) ;
16691677 register_ci_collection ( & mut ctx, "products" , "product_id" ) . await ;
16701678
1671- let before = query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1672- let before_count = total_rows ( & before) ;
1679+ // Verify a known row exists before and survives a no-op delete
1680+ let before = query_all (
1681+ & ctx,
1682+ "SELECT product_id FROM products WHERE product_id = 'PROD001'" ,
1683+ )
1684+ . await ;
1685+ assert_eq ! ( total_rows( & before) , 1 ) ;
16731686
16741687 ctx. sql ( "DELETE FROM products WHERE product_id = 'NONEXISTENT'" )
16751688 . await
@@ -1678,8 +1691,12 @@ mod tests {
16781691 . await
16791692 . expect ( "execute delete" ) ;
16801693
1681- let after = query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1682- assert_eq ! ( total_rows( & after) , before_count) ;
1694+ let after = query_all (
1695+ & ctx,
1696+ "SELECT product_id FROM products WHERE product_id = 'PROD001'" ,
1697+ )
1698+ . await ;
1699+ assert_eq ! ( total_rows( & after) , 1 ) ;
16831700 }
16841701
16851702 // ─── Update tests (integration) ─────────────────────────────────────
@@ -1718,8 +1735,19 @@ mod tests {
17181735 let mut ctx = SessionContext :: new ( ) ;
17191736 register_ci_collection ( & mut ctx, "products" , "product_id" ) . await ;
17201737
1721- let before = query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1722- let before_count = total_rows ( & before) ;
1738+ // Verify a known row is unchanged after a no-op update
1739+ let before = query_all (
1740+ & ctx,
1741+ "SELECT price FROM products WHERE product_id = 'PROD002'" ,
1742+ )
1743+ . await ;
1744+ assert_eq ! ( total_rows( & before) , 1 ) ;
1745+ let price_before = before[ 0 ]
1746+ . column ( 0 )
1747+ . as_any ( )
1748+ . downcast_ref :: < Float64Array > ( )
1749+ . unwrap ( )
1750+ . value ( 0 ) ;
17231751
17241752 ctx. sql ( "UPDATE products SET price = 0.0 WHERE product_id = 'NONEXISTENT'" )
17251753 . await
@@ -1728,8 +1756,19 @@ mod tests {
17281756 . await
17291757 . expect ( "execute update" ) ;
17301758
1731- let after = query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1732- assert_eq ! ( total_rows( & after) , before_count) ;
1759+ let after = query_all (
1760+ & ctx,
1761+ "SELECT price FROM products WHERE product_id = 'PROD002'" ,
1762+ )
1763+ . await ;
1764+ assert_eq ! ( total_rows( & after) , 1 ) ;
1765+ let price_after = after[ 0 ]
1766+ . column ( 0 )
1767+ . as_any ( )
1768+ . downcast_ref :: < Float64Array > ( )
1769+ . unwrap ( )
1770+ . value ( 0 ) ;
1771+ assert ! ( ( price_before - price_after) . abs( ) < 0.01 ) ;
17331772 }
17341773
17351774 // ─── Combined DML test (integration) ────────────────────────────────
@@ -1740,9 +1779,6 @@ mod tests {
17401779 let mut ctx = SessionContext :: new ( ) ;
17411780 register_ci_collection ( & mut ctx, "products" , "product_id" ) . await ;
17421781
1743- let before = query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1744- let before_count = total_rows ( & before) ;
1745-
17461782 // 1. Insert
17471783 ctx. sql (
17481784 "INSERT INTO products (product_id, name, category, price, in_stock)
@@ -1753,8 +1789,12 @@ mod tests {
17531789 . collect ( )
17541790 . await
17551791 . unwrap ( ) ;
1756- let after_insert = query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1757- assert_eq ! ( total_rows( & after_insert) , before_count + 1 ) ;
1792+ let after_insert = query_all (
1793+ & ctx,
1794+ "SELECT product_id FROM products WHERE product_id = 'PROD_RT'" ,
1795+ )
1796+ . await ;
1797+ assert_eq ! ( total_rows( & after_insert) , 1 ) ;
17581798
17591799 // 2. Update
17601800 ctx. sql ( "UPDATE products SET price = 20.0, name = 'RoundTripUpdated' WHERE product_id = 'PROD_RT'" )
@@ -1782,8 +1822,12 @@ mod tests {
17821822 . collect ( )
17831823 . await
17841824 . unwrap ( ) ;
1785- let after_delete = query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1786- assert_eq ! ( total_rows( & after_delete) , before_count) ;
1825+ let after_delete = query_all (
1826+ & ctx,
1827+ "SELECT product_id FROM products WHERE product_id = 'PROD_RT'" ,
1828+ )
1829+ . await ;
1830+ assert_eq ! ( total_rows( & after_delete) , 0 ) ;
17871831 }
17881832
17891833 // ─── Category filter test (integration) ─────────────────────────────
0 commit comments