From 5630c6160f451fedb0608da6d32646d638f452ed Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Sat, 12 Nov 2022 05:08:01 -0800 Subject: [PATCH] Rename prep_allocator --- src/api/services/communities.zig | 2 +- src/api/services/notes.zig | 2 +- src/sql/engines/common.zig | 2 +- src/sql/engines/postgres.zig | 2 +- src/sql/lib.zig | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/services/communities.zig b/src/api/services/communities.zig index 45e2fe1..780b7d5 100644 --- a/src/api/services/communities.zig +++ b/src/api/services/communities.zig @@ -286,7 +286,7 @@ pub fn query(db: anytype, args: QueryArgs, alloc: std.mem.Allocator) !QueryResul std.meta.assumeSentinel(builder.array.items, 0), query_args, max_items, - .{ .prep_allocator = alloc, .ignore_unused_arguments = true }, + .{ .allocator = alloc, .ignore_unused_arguments = true }, ); errdefer util.deepFree(alloc, results); diff --git a/src/api/services/notes.zig b/src/api/services/notes.zig index 5156530..ddb3b01 100644 --- a/src/api/services/notes.zig +++ b/src/api/services/notes.zig @@ -130,7 +130,7 @@ pub fn query(db: anytype, args: QueryArgs, alloc: std.mem.Allocator) !QueryResul try builder.terminate(), query_args, max_items, - .{ .prep_allocator = alloc, .ignore_unused_arguments = true }, + .{ .allocator = alloc, .ignore_unused_arguments = true }, ); errdefer util.deepFree(results); diff --git a/src/sql/engines/common.zig b/src/sql/engines/common.zig index 67fef2f..b50b7d0 100644 --- a/src/sql/engines/common.zig +++ b/src/sql/engines/common.zig @@ -68,7 +68,7 @@ pub const QueryOptions = struct { // do not require allocators for prep. If an allocator is needed but not // provided, `error.AllocatorRequired` will be returned. // Only used with the postgres backend. - prep_allocator: ?Allocator = null, + allocator: ?Allocator = null, }; // Turns a value into its appropriate textual value (or null) diff --git a/src/sql/engines/postgres.zig b/src/sql/engines/postgres.zig index 6bff648..bb24415 100644 --- a/src/sql/engines/postgres.zig +++ b/src/sql/engines/postgres.zig @@ -180,7 +180,7 @@ pub const Db = struct { const format_text = 0; const format_binary = 1; pub fn exec(self: Db, sql: [:0]const u8, args: anytype, opt: common.QueryOptions) common.ExecError!Results { - const alloc = opt.prep_allocator; + const alloc = opt.allocator; const result = blk: { if (@TypeOf(args) != void and args.len > 0) { var arena = std.heap.ArenaAllocator.init(alloc orelse return error.AllocatorRequired); diff --git a/src/sql/lib.zig b/src/sql/lib.zig index 830f7a1..9b1f599 100644 --- a/src/sql/lib.zig +++ b/src/sql/lib.zig @@ -458,7 +458,7 @@ fn Tx(comptime tx_level: u8) type { args: anytype, alloc: ?Allocator, ) QueryError!Results(RowType) { - return self.queryWithOptions(RowType, sql, args, .{ .prep_allocator = alloc }); + return self.queryWithOptions(RowType, sql, args, .{ .allocator = alloc }); } /// Runs a query to completion and returns a row of results, unless the query @@ -499,7 +499,7 @@ fn Tx(comptime tx_level: u8) type { var results = try self.queryWithOptions(RowType, q, args, options); defer results.finish(); - const alloc = options.prep_allocator orelse return error.AllocatorRequired; + const alloc = options.allocator orelse return error.AllocatorRequired; var result_array = std.ArrayList(RowType).init(alloc); errdefer result_array.deinit(); @@ -586,7 +586,7 @@ fn Tx(comptime tx_level: u8) type { alloc: ?std.mem.Allocator, comptime check_tx: bool, ) !void { - var results = try self.runSql(sql, args, .{ .prep_allocator = alloc }, check_tx); + var results = try self.runSql(sql, args, .{ .allocator = alloc }, check_tx); defer results.finish(); while (try results.row()) |_| {}