stoolap 0.4.0

High-performance embedded SQL database with MVCC, time-travel queries, and full ACID compliance
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
// Copyright 2025 Stoolap Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Regression tests for Bug Batch 3
// Tests for bugs discovered during exploratory testing

use stoolap::Database;

fn setup_db() -> Database {
    Database::open_in_memory().expect("Failed to create in-memory database")
}

// =============================================================================
// BUG 1: Window ORDER BY with COALESCE on aggregate
// Problem: RANK() OVER (ORDER BY COALESCE(SUM(val), 0)) returned all rank 1
// =============================================================================

#[test]
fn test_bugs3_window_coalesce_aggregate() {
    let db = setup_db();

    // Setup
    db.execute(
        "CREATE TABLE window_coalesce_test (grp TEXT, val INTEGER)",
        (),
    )
    .expect("Failed to create table");
    db.execute(
        "INSERT INTO window_coalesce_test VALUES ('A', 10), ('B', 30), ('C', 20)",
        (),
    )
    .expect("Failed to insert data");

    // Test RANK with COALESCE on aggregate in ORDER BY
    let mut rows = db
        .query(
            "SELECT grp, COALESCE(SUM(val), 0) as total, \
             RANK() OVER (ORDER BY COALESCE(SUM(val), 0) DESC) as rnk \
             FROM window_coalesce_test GROUP BY grp ORDER BY rnk",
            (),
        )
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<String>(0).unwrap(), "B");
    assert_eq!(row.get::<i64>(1).unwrap(), 30);
    assert_eq!(row.get::<i64>(2).unwrap(), 1);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<String>(0).unwrap(), "C");
    assert_eq!(row.get::<i64>(1).unwrap(), 20);
    assert_eq!(row.get::<i64>(2).unwrap(), 2);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<String>(0).unwrap(), "A");
    assert_eq!(row.get::<i64>(1).unwrap(), 10);
    assert_eq!(row.get::<i64>(2).unwrap(), 3);
}

#[test]
fn test_bugs3_window_dense_rank_coalesce() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE dense_rank_test (grp TEXT, val INTEGER)", ())
        .expect("Failed to create table");
    db.execute(
        "INSERT INTO dense_rank_test VALUES ('A', 10), ('B', 20), ('C', 20)",
        (),
    )
    .expect("Failed to insert data");

    // Test DENSE_RANK with COALESCE
    let mut rows = db
        .query(
            "SELECT grp, COALESCE(SUM(val), 0) as total, \
             DENSE_RANK() OVER (ORDER BY COALESCE(SUM(val), 0) DESC) as rnk \
             FROM dense_rank_test GROUP BY grp ORDER BY grp",
            (),
        )
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<String>(0).unwrap(), "A");
    assert_eq!(row.get::<i64>(2).unwrap(), 2); // A=10 gets rank 2

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<String>(0).unwrap(), "B");
    assert_eq!(row.get::<i64>(2).unwrap(), 1); // B=20 gets rank 1

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<String>(0).unwrap(), "C");
    assert_eq!(row.get::<i64>(2).unwrap(), 1); // C=20 gets rank 1
}

#[test]
fn test_bugs3_window_row_number_coalesce() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE row_num_test (grp TEXT, val INTEGER)", ())
        .expect("Failed to create table");
    db.execute(
        "INSERT INTO row_num_test VALUES ('A', 10), ('B', 30), ('C', 20)",
        (),
    )
    .expect("Failed to insert data");

    // Test ROW_NUMBER with COALESCE
    let mut rows = db
        .query(
            "SELECT grp, COALESCE(SUM(val), 0) as total, \
             ROW_NUMBER() OVER (ORDER BY COALESCE(SUM(val), 0) DESC) as rn \
             FROM row_num_test GROUP BY grp ORDER BY rn",
            (),
        )
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<String>(0).unwrap(), "B");
    assert_eq!(row.get::<i64>(2).unwrap(), 1);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<String>(0).unwrap(), "C");
    assert_eq!(row.get::<i64>(2).unwrap(), 2);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<String>(0).unwrap(), "A");
    assert_eq!(row.get::<i64>(2).unwrap(), 3);
}

// =============================================================================
// BUG 2: JOIN between subqueries ignores ON condition
// Problem: SELECT * FROM (SELECT..) a JOIN (SELECT..) b ON a.id = b.id
//          produced a CROSS JOIN instead of applying ON condition
// =============================================================================

#[test]
fn test_bugs3_subquery_join_on_condition() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE subq_a (id INTEGER, val TEXT)", ())
        .expect("Failed to create table");
    db.execute("CREATE TABLE subq_b (id INTEGER, data TEXT)", ())
        .expect("Failed to create table");
    db.execute("INSERT INTO subq_a VALUES (1, 'a'), (2, 'b')", ())
        .expect("Failed to insert data");
    db.execute("INSERT INTO subq_b VALUES (1, 'x'), (3, 'y')", ())
        .expect("Failed to insert data");

    // Test JOIN between subqueries with ON condition
    let mut rows = db
        .query(
            "SELECT * FROM (SELECT * FROM subq_a) AS a \
             JOIN (SELECT * FROM subq_b) AS b ON a.id = b.id",
            (),
        )
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 1); // a.id
    assert_eq!(row.get::<String>(1).unwrap(), "a"); // a.val
    assert_eq!(row.get::<i64>(2).unwrap(), 1); // b.id
    assert_eq!(row.get::<String>(3).unwrap(), "x"); // b.data

    // Should only have 1 row where id=1 matches
    assert!(
        rows.next().is_none(),
        "Should have only 1 row (only id=1 matches)"
    );
}

#[test]
fn test_bugs3_subquery_left_join() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE left_a (id INTEGER, val TEXT)", ())
        .expect("Failed to create table");
    db.execute("CREATE TABLE left_b (id INTEGER, data TEXT)", ())
        .expect("Failed to create table");
    db.execute("INSERT INTO left_a VALUES (1, 'a'), (2, 'b')", ())
        .expect("Failed to insert data");
    db.execute("INSERT INTO left_b VALUES (1, 'x'), (3, 'y')", ())
        .expect("Failed to insert data");

    // Test LEFT JOIN between subqueries
    let mut rows = db
        .query(
            "SELECT * FROM (SELECT * FROM left_a) AS a \
             LEFT JOIN (SELECT * FROM left_b) AS b ON a.id = b.id \
             ORDER BY a.id",
            (),
        )
        .expect("Query failed");

    // First row: id=1 matched
    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 1);
    assert_eq!(row.get::<String>(1).unwrap(), "a");
    assert_eq!(row.get::<i64>(2).unwrap(), 1);
    assert_eq!(row.get::<String>(3).unwrap(), "x");

    // Second row: id=2 unmatched (right side should be NULL)
    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 2);
    assert_eq!(row.get::<String>(1).unwrap(), "b");
    // Check that b.id is NULL
    let value = row.get_value(2);
    assert!(
        value.map(|v| v.is_null()).unwrap_or(true),
        "b.id should be NULL for unmatched row"
    );

    assert!(rows.next().is_none(), "Should have only 2 rows");
}

#[test]
fn test_bugs3_regular_table_join_still_works() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE reg_a (id INTEGER, val TEXT)", ())
        .expect("Failed to create table");
    db.execute("CREATE TABLE reg_b (id INTEGER, data TEXT)", ())
        .expect("Failed to create table");
    db.execute("INSERT INTO reg_a VALUES (1, 'a'), (2, 'b')", ())
        .expect("Failed to insert data");
    db.execute("INSERT INTO reg_b VALUES (1, 'x'), (3, 'y')", ())
        .expect("Failed to insert data");

    // Regression test: regular table JOIN should still work
    let mut rows = db
        .query("SELECT * FROM reg_a a JOIN reg_b b ON a.id = b.id", ())
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 1);

    assert!(rows.next().is_none(), "Should have only 1 row");
}

// =============================================================================
// BUG 3: INSERT RETURNING doesn't show AUTO_INCREMENT values
// Problem: INSERT INTO t (name) VALUES ('x') RETURNING * showed NULL for id
// =============================================================================

#[test]
fn test_bugs3_insert_returning_auto_increment() {
    let db = setup_db();

    // Setup
    db.execute(
        "CREATE TABLE auto_ret_test (id INTEGER PRIMARY KEY AUTO_INCREMENT, name TEXT)",
        (),
    )
    .expect("Failed to create table");

    // Test INSERT RETURNING with AUTO_INCREMENT
    let mut rows = db
        .query(
            "INSERT INTO auto_ret_test (name) VALUES ('test1') RETURNING *",
            (),
        )
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    // The AUTO_INCREMENT id should be 1, not NULL
    let id = row.get::<i64>(0).unwrap();
    assert_eq!(id, 1, "AUTO_INCREMENT id should be 1, got {}", id);
    assert_eq!(row.get::<String>(1).unwrap(), "test1");

    assert!(rows.next().is_none(), "Should return only 1 row");
}

#[test]
fn test_bugs3_insert_returning_auto_increment_multiple() {
    let db = setup_db();

    // Setup
    db.execute(
        "CREATE TABLE auto_multi_test (id INTEGER PRIMARY KEY AUTO_INCREMENT, name TEXT)",
        (),
    )
    .expect("Failed to create table");

    // Insert multiple rows and check RETURNING
    let mut rows1 = db
        .query(
            "INSERT INTO auto_multi_test (name) VALUES ('first') RETURNING id",
            (),
        )
        .expect("Query failed");
    let row = rows1.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 1);

    let mut rows2 = db
        .query(
            "INSERT INTO auto_multi_test (name) VALUES ('second') RETURNING id",
            (),
        )
        .expect("Query failed");
    let row = rows2.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 2);

    let mut rows3 = db
        .query(
            "INSERT INTO auto_multi_test (name) VALUES ('third') RETURNING id",
            (),
        )
        .expect("Query failed");
    let row = rows3.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 3);
}

#[test]
fn test_bugs3_insert_returning_specific_columns() {
    let db = setup_db();

    // Setup
    db.execute(
        "CREATE TABLE auto_cols_test (id INTEGER PRIMARY KEY AUTO_INCREMENT, name TEXT, age INTEGER)",
        (),
    )
    .expect("Failed to create table");

    // Test RETURNING specific columns including AUTO_INCREMENT
    let mut rows = db
        .query(
            "INSERT INTO auto_cols_test (name, age) VALUES ('Alice', 30) RETURNING id, name",
            (),
        )
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 1); // id should be 1
    assert_eq!(row.get::<String>(1).unwrap(), "Alice");
}

#[test]
fn test_bugs3_insert_returning_with_explicit_id() {
    let db = setup_db();

    // Setup
    db.execute(
        "CREATE TABLE auto_explicit_test (id INTEGER PRIMARY KEY AUTO_INCREMENT, name TEXT)",
        (),
    )
    .expect("Failed to create table");

    // Insert with explicit ID
    let mut rows = db
        .query(
            "INSERT INTO auto_explicit_test (id, name) VALUES (100, 'explicit') RETURNING *",
            (),
        )
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 100); // explicit ID should be preserved

    // Next auto-increment should be 101
    let mut rows2 = db
        .query(
            "INSERT INTO auto_explicit_test (name) VALUES ('next') RETURNING id",
            (),
        )
        .expect("Query failed");
    let row = rows2.next().unwrap().unwrap();
    assert_eq!(
        row.get::<i64>(0).unwrap(),
        101,
        "Next AUTO_INCREMENT should be 101 after explicit 100"
    );
}

// =============================================================================
// BUG 4: WHERE clause with expression compared to column fails
// Problem: WHERE a * 2 = b returned no rows when expression equals column value
// Root cause: evaluate_literal_with_ctx silently returned NULL for expressions
//             containing column references instead of returning an error
// =============================================================================

#[test]
fn test_bugs3_where_expression_equals_column() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE expr_cmp (a INTEGER, b INTEGER)", ())
        .expect("Failed to create table");
    db.execute("INSERT INTO expr_cmp VALUES (2, 4), (3, 6), (5, 10)", ())
        .expect("Failed to insert data");

    // Test: expression = column
    let mut rows = db
        .query("SELECT * FROM expr_cmp WHERE a * 2 = b ORDER BY a", ())
        .expect("Query failed");

    // All rows should match since 2*2=4, 3*2=6, 5*2=10
    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 2);
    assert_eq!(row.get::<i64>(1).unwrap(), 4);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 3);
    assert_eq!(row.get::<i64>(1).unwrap(), 6);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 5);
    assert_eq!(row.get::<i64>(1).unwrap(), 10);

    assert!(rows.next().is_none());
}

#[test]
fn test_bugs3_where_column_equals_expression() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE expr_cmp2 (a INTEGER, b INTEGER)", ())
        .expect("Failed to create table");
    db.execute("INSERT INTO expr_cmp2 VALUES (2, 4), (3, 6), (5, 10)", ())
        .expect("Failed to insert data");

    // Test: column = expression
    let mut rows = db
        .query("SELECT * FROM expr_cmp2 WHERE a = b / 2 ORDER BY a", ())
        .expect("Query failed");

    // All rows should match since 4/2=2, 6/2=3, 10/2=5
    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 2);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 3);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 5);

    assert!(rows.next().is_none());
}

#[test]
fn test_bugs3_where_expression_greater_than_column() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE expr_cmp3 (a INTEGER, b INTEGER)", ())
        .expect("Failed to create table");
    db.execute("INSERT INTO expr_cmp3 VALUES (2, 4), (3, 6), (5, 10)", ())
        .expect("Failed to insert data");

    // Test: expression > column
    let mut rows = db
        .query("SELECT * FROM expr_cmp3 WHERE a * 3 > b ORDER BY a", ())
        .expect("Query failed");

    // All rows should match: 2*3=6>4, 3*3=9>6, 5*3=15>10
    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 2);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 3);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 5);

    assert!(rows.next().is_none());
}

#[test]
fn test_bugs3_where_both_sides_expressions() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE expr_cmp4 (a INTEGER, b INTEGER)", ())
        .expect("Failed to create table");
    db.execute("INSERT INTO expr_cmp4 VALUES (2, 4), (3, 7), (5, 10)", ())
        .expect("Failed to insert data");

    // Test: expression = expression (this already worked, regression test)
    let mut rows = db
        .query("SELECT * FROM expr_cmp4 WHERE a * 2 = b * 1 ORDER BY a", ())
        .expect("Query failed");

    // Only (2,4) and (5,10) match: 2*2=4*1, 5*2=10*1
    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 2);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 5);

    assert!(rows.next().is_none());
}

#[test]
fn test_bugs3_where_expression_minus_column_equals_zero() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE expr_cmp5 (a INTEGER, b INTEGER)", ())
        .expect("Failed to create table");
    db.execute("INSERT INTO expr_cmp5 VALUES (2, 4), (3, 6), (5, 10)", ())
        .expect("Failed to insert data");

    // Test: expression - column = literal (this already worked, regression test)
    let mut rows = db
        .query("SELECT * FROM expr_cmp5 WHERE a * 2 - b = 0 ORDER BY a", ())
        .expect("Query failed");

    // All rows should match
    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 2);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 3);

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 5);

    assert!(rows.next().is_none());
}

#[test]
fn test_bugs3_delete_with_expression_comparison() {
    let db = setup_db();

    // Setup WITH primary key (required for DELETE with complex WHERE)
    db.execute(
        "CREATE TABLE delete_expr (id INTEGER PRIMARY KEY, a INTEGER, b INTEGER)",
        (),
    )
    .expect("Failed to create table");
    db.execute(
        "INSERT INTO delete_expr VALUES (1, 1, 2), (2, 2, 4), (3, 3, 5)",
        (),
    )
    .expect("Failed to insert data");

    // Delete rows where a * 2 = b (should delete id=1 and id=2)
    db.execute("DELETE FROM delete_expr WHERE a * 2 = b", ())
        .expect("Delete failed");

    // Only id=3 should remain
    let mut rows = db
        .query("SELECT * FROM delete_expr ORDER BY id", ())
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 3);
    assert_eq!(row.get::<i64>(1).unwrap(), 3);
    assert_eq!(row.get::<i64>(2).unwrap(), 5);

    assert!(rows.next().is_none(), "Should have only 1 row after delete");
}

#[test]
fn test_bugs3_update_with_expression_comparison() {
    let db = setup_db();

    // Setup
    db.execute("CREATE TABLE update_expr (a INTEGER, b INTEGER)", ())
        .expect("Failed to create table");
    db.execute("INSERT INTO update_expr VALUES (2, 4), (3, 6), (5, 10)", ())
        .expect("Failed to insert data");

    // Update rows where a * 2 = b (all rows should match)
    db.execute("UPDATE update_expr SET b = b + 1 WHERE a * 2 = b", ())
        .expect("Update failed");

    // All b values should be incremented by 1
    let mut rows = db
        .query("SELECT * FROM update_expr ORDER BY a", ())
        .expect("Query failed");

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 2);
    assert_eq!(row.get::<i64>(1).unwrap(), 5); // was 4, now 5

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 3);
    assert_eq!(row.get::<i64>(1).unwrap(), 7); // was 6, now 7

    let row = rows.next().unwrap().unwrap();
    assert_eq!(row.get::<i64>(0).unwrap(), 5);
    assert_eq!(row.get::<i64>(1).unwrap(), 11); // was 10, now 11

    assert!(rows.next().is_none());
}