Skip to content

Commit 3248725

Browse files
committed
readme: fix examples
1 parent 7f65f8f commit 3248725

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,9 @@ Take the following code:
469469
var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?");
470470
defer stmt.deinit();
471471
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, .{}, .{
473475
.age_1 = 10,
474476
.age_2 = 20,
475477
});
@@ -504,7 +506,9 @@ For example, take the same code as above but now we also bind the last parameter
504506
var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?");
505507
defer stmt.deinit();
506508
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, .{}, .{
508512
.age_1 = 10,
509513
.age_2 = 20,
510514
.weight = false,
@@ -519,7 +523,7 @@ We can make sure the bind parameters have the right type if we rewrite the query
519523
var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?{usize}");
520524
defer stmt.deinit();
521525
522-
const rows = try stmt.all(usize, .{ .allocator = allocator }, .{
526+
const rows = try stmt.all(usize, allocator, .{}, .{
523527
.age_1 = 10,
524528
.age_2 = 20,
525529
.weight = false,

0 commit comments

Comments
 (0)