mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
fix(Bun.SQL) fix IN, UPDATE support in helpers, and fix JSONB/JSON serialization (#22700)
### What does this PR do? Fixes https://github.com/oven-sh/bun/issues/20669 Fixes https://github.com/oven-sh/bun/issues/18775 Fixes https://github.com/oven-sh/bun/issues/22156 Fixes https://github.com/oven-sh/bun/issues/22164 Fixes https://github.com/oven-sh/bun/issues/18254 Fixes https://github.com/oven-sh/bun/issues/21267 Fixes https://github.com/oven-sh/bun/issues/20669 Fixes https://github.com/oven-sh/bun/issues/1317 Fixes https://github.com/oven-sh/bun/pull/22700 Partially Fixes https://github.com/oven-sh/bun/issues/22757 (sqlite pending, need a followup and probably @alii help here) ### How did you verify your code works? Tests --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,6 @@ pub const @"bool" = @import("./types/bool.zig");
|
||||
pub const bytea = @import("./types/bytea.zig");
|
||||
pub const date = @import("./types/date.zig");
|
||||
pub const json = @import("./types/json.zig");
|
||||
pub const numeric = @import("./types/numeric.zig");
|
||||
pub const string = @import("./types/PostgresString.zig");
|
||||
pub const AnyPostgresError = @import("./AnyPostgresError.zig").AnyPostgresError;
|
||||
pub const Tag = @import("./types/Tag.zig").Tag;
|
||||
|
||||
@@ -271,11 +271,11 @@ pub const Tag = enum(short) {
|
||||
) AnyPostgresError!JSValue {
|
||||
switch (tag) {
|
||||
.numeric => {
|
||||
return numeric.toJS(globalObject, value);
|
||||
return JSValue.jsNumber(value);
|
||||
},
|
||||
|
||||
.float4, .float8 => {
|
||||
return numeric.toJS(globalObject, value);
|
||||
return JSValue.jsNumber(value);
|
||||
},
|
||||
|
||||
.json, .jsonb => {
|
||||
@@ -299,7 +299,7 @@ pub const Tag = enum(short) {
|
||||
},
|
||||
|
||||
.int4 => {
|
||||
return numeric.toJS(globalObject, value);
|
||||
return JSValue.jsNumber(value);
|
||||
},
|
||||
|
||||
else => {
|
||||
@@ -342,8 +342,9 @@ pub const Tag = enum(short) {
|
||||
return .int8;
|
||||
}
|
||||
|
||||
if (tag.isArrayLike() and try value.getLength(globalObject) > 0) {
|
||||
return Tag.fromJS(globalObject, try value.getIndex(globalObject, 0));
|
||||
if (tag.isArrayLike()) {
|
||||
// We will JSON.stringify anything else.
|
||||
return .json;
|
||||
}
|
||||
|
||||
// Ban these types:
|
||||
@@ -397,7 +398,6 @@ const bun = @import("bun");
|
||||
const bytea = @import("./bytea.zig");
|
||||
const date = @import("./date.zig");
|
||||
const json = @import("./json.zig");
|
||||
const numeric = @import("./numeric.zig");
|
||||
const std = @import("std");
|
||||
const string = @import("./PostgresString.zig");
|
||||
const AnyPostgresError = @import("../AnyPostgresError.zig").AnyPostgresError;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
pub const to = 0;
|
||||
pub const from = [_]short{ 21, 23, 26, 700, 701 };
|
||||
|
||||
pub fn toJS(
|
||||
_: *jsc.JSGlobalObject,
|
||||
value: anytype,
|
||||
) AnyPostgresError!JSValue {
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
|
||||
const bun = @import("bun");
|
||||
const AnyPostgresError = @import("../AnyPostgresError.zig").AnyPostgresError;
|
||||
|
||||
const int_types = @import("./int_types.zig");
|
||||
const short = int_types.short;
|
||||
|
||||
const jsc = bun.jsc;
|
||||
const JSValue = jsc.JSValue;
|
||||
Reference in New Issue
Block a user