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),
|
std.meta.assumeSentinel(builder.array.items, 0),
|
||||||
query_args,
|
query_args,
|
||||||
max_items,
|
max_items,
|
||||||
.{ .prep_allocator = alloc, .ignore_unused_arguments = true },
|
.{ .allocator = alloc, .ignore_unused_arguments = true },
|
||||||
);
|
);
|
||||||
errdefer util.deepFree(alloc, results);
|
errdefer util.deepFree(alloc, results);
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ pub fn query(db: anytype, args: QueryArgs, alloc: std.mem.Allocator) !QueryResul
|
||||||
try builder.terminate(),
|
try builder.terminate(),
|
||||||
query_args,
|
query_args,
|
||||||
max_items,
|
max_items,
|
||||||
.{ .prep_allocator = alloc, .ignore_unused_arguments = true },
|
.{ .allocator = alloc, .ignore_unused_arguments = true },
|
||||||
);
|
);
|
||||||
errdefer util.deepFree(results);
|
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
|
// do not require allocators for prep. If an allocator is needed but not
|
||||||
// provided, `error.AllocatorRequired` will be returned.
|
// provided, `error.AllocatorRequired` will be returned.
|
||||||
// Only used with the postgres backend.
|
// Only used with the postgres backend.
|
||||||
prep_allocator: ?Allocator = null,
|
allocator: ?Allocator = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Turns a value into its appropriate textual value (or 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_text = 0;
|
||||||
const format_binary = 1;
|
const format_binary = 1;
|
||||||
pub fn exec(self: Db, sql: [:0]const u8, args: anytype, opt: common.QueryOptions) common.ExecError!Results {
|
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: {
|
const result = blk: {
|
||||||
if (@TypeOf(args) != void and args.len > 0) {
|
if (@TypeOf(args) != void and args.len > 0) {
|
||||||
var arena = std.heap.ArenaAllocator.init(alloc orelse return error.AllocatorRequired);
|
var arena = std.heap.ArenaAllocator.init(alloc orelse return error.AllocatorRequired);
|
||||||
|
|
|
@ -458,7 +458,7 @@ fn Tx(comptime tx_level: u8) type {
|
||||||
args: anytype,
|
args: anytype,
|
||||||
alloc: ?Allocator,
|
alloc: ?Allocator,
|
||||||
) QueryError!Results(RowType) {
|
) 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
|
/// 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);
|
var results = try self.queryWithOptions(RowType, q, args, options);
|
||||||
defer results.finish();
|
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);
|
var result_array = std.ArrayList(RowType).init(alloc);
|
||||||
errdefer result_array.deinit();
|
errdefer result_array.deinit();
|
||||||
|
@ -586,7 +586,7 @@ fn Tx(comptime tx_level: u8) type {
|
||||||
alloc: ?std.mem.Allocator,
|
alloc: ?std.mem.Allocator,
|
||||||
comptime check_tx: bool,
|
comptime check_tx: bool,
|
||||||
) !void {
|
) !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();
|
defer results.finish();
|
||||||
|
|
||||||
while (try results.row()) |_| {}
|
while (try results.row()) |_| {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue