mirror of
https://github.com/oven-sh/bun
synced 2026-02-19 15:21:54 +00:00
refactor(postgres) improve postgres code base (#20808)
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com>
This commit is contained in:
34
src/sql/postgres/PostgresCachedStructure.zig
Normal file
34
src/sql/postgres/PostgresCachedStructure.zig
Normal file
@@ -0,0 +1,34 @@
|
||||
structure: JSC.Strong.Optional = .empty,
|
||||
// only populated if more than JSC.JSC__JSObject__maxInlineCapacity fields otherwise the structure will contain all fields inlined
|
||||
fields: ?[]JSC.JSObject.ExternColumnIdentifier = null,
|
||||
|
||||
pub fn has(this: *@This()) bool {
|
||||
return this.structure.has() or this.fields != null;
|
||||
}
|
||||
|
||||
pub fn jsValue(this: *const @This()) ?JSC.JSValue {
|
||||
return this.structure.get();
|
||||
}
|
||||
|
||||
pub fn set(this: *@This(), globalObject: *JSC.JSGlobalObject, value: ?JSC.JSValue, fields: ?[]JSC.JSObject.ExternColumnIdentifier) void {
|
||||
if (value) |v| {
|
||||
this.structure.set(globalObject, v);
|
||||
}
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
pub fn deinit(this: *@This()) void {
|
||||
this.structure.deinit();
|
||||
if (this.fields) |fields| {
|
||||
this.fields = null;
|
||||
for (fields) |*name| {
|
||||
name.deinit();
|
||||
}
|
||||
bun.default_allocator.free(fields);
|
||||
}
|
||||
}
|
||||
|
||||
// @sortImports
|
||||
|
||||
const bun = @import("bun");
|
||||
const JSC = bun.JSC;
|
||||
Reference in New Issue
Block a user