File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -469,7 +469,9 @@ Take the following code:
469
469
var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?");
470
470
defer stmt.deinit();
471
471
472
- const rows = try stmt.all(usize, .{}, .{
472
+ const allocator = std.heap.page_allocator; // Use a suitable allocator
473
+
474
+ const rows = try stmt.all(usize, allocator, .{}, .{
473
475
.age_1 = 10,
474
476
.age_2 = 20,
475
477
});
@@ -504,7 +506,9 @@ For example, take the same code as above but now we also bind the last parameter
504
506
var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?");
505
507
defer stmt.deinit();
506
508
507
- const rows = try stmt.all(usize, .{ .allocator = allocator }, .{
509
+ const allocator = std.heap.page_allocator; // Use a suitable allocator
510
+
511
+ const rows = try stmt.all(usize, allocator, .{}, .{
508
512
.age_1 = 10,
509
513
.age_2 = 20,
510
514
.weight = false,
@@ -519,7 +523,7 @@ We can make sure the bind parameters have the right type if we rewrite the query
519
523
var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?{usize}");
520
524
defer stmt.deinit();
521
525
522
- const rows = try stmt.all(usize, .{ . allocator = allocator }, .{
526
+ const rows = try stmt.all(usize, allocator, .{ }, .{
523
527
.age_1 = 10,
524
528
.age_2 = 20,
525
529
.weight = false,
You can’t perform that action at this time.
0 commit comments