Rename prep_allocator
This commit is contained in:
parent
139fc92854
commit
5630c6160f
5 changed files with 7 additions and 7 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()) |_| {}
|
||||
|
|
Loading…
Reference in a new issue