mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 19:38:58 +00:00
safety: a lot more exception checker progress (#20956)
This commit is contained in:
@@ -273,7 +273,7 @@ pub const DataCell = extern struct {
|
||||
const date_str = slice[1..current_idx];
|
||||
var str = bun.String.init(date_str);
|
||||
defer str.deref();
|
||||
try array.append(bun.default_allocator, DataCell{ .tag = .date, .value = .{ .date = str.parseDate(globalObject) } });
|
||||
try array.append(bun.default_allocator, DataCell{ .tag = .date, .value = .{ .date = try str.parseDate(globalObject) } });
|
||||
|
||||
slice = trySlice(slice, current_idx + 1);
|
||||
continue;
|
||||
@@ -370,7 +370,7 @@ pub const DataCell = extern struct {
|
||||
if (arrayType == .date_array) {
|
||||
var str = bun.String.init(element);
|
||||
defer str.deref();
|
||||
try array.append(bun.default_allocator, DataCell{ .tag = .date, .value = .{ .date = str.parseDate(globalObject) } });
|
||||
try array.append(bun.default_allocator, DataCell{ .tag = .date, .value = .{ .date = try str.parseDate(globalObject) } });
|
||||
} else {
|
||||
// the only escape sequency possible here is \b
|
||||
if (bun.strings.eqlComptime(element, "\\b")) {
|
||||
@@ -723,7 +723,7 @@ pub const DataCell = extern struct {
|
||||
} else {
|
||||
var str = bun.String.init(bytes);
|
||||
defer str.deref();
|
||||
return DataCell{ .tag = .date, .value = .{ .date = str.parseDate(globalObject) } };
|
||||
return DataCell{ .tag = .date, .value = .{ .date = try str.parseDate(globalObject) } };
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ pub fn writeBind(
|
||||
},
|
||||
.timestamp, .timestamptz => {
|
||||
const l = try writer.length();
|
||||
try writer.int8(types.date.fromJS(globalObject, value));
|
||||
try writer.int8(try types.date.fromJS(globalObject, value));
|
||||
try l.writeExcludingSelf();
|
||||
},
|
||||
.bytea => {
|
||||
|
||||
@@ -11,7 +11,7 @@ pub fn fromBinary(bytes: []const u8) f64 {
|
||||
return (double_microseconds / std.time.us_per_ms) + POSTGRES_EPOCH_DATE;
|
||||
}
|
||||
|
||||
pub fn fromJS(globalObject: *JSC.JSGlobalObject, value: JSValue) i64 {
|
||||
pub fn fromJS(globalObject: *JSC.JSGlobalObject, value: JSValue) bun.JSError!i64 {
|
||||
const double_value = if (value.isDate())
|
||||
value.getUnixTimestamp()
|
||||
else if (value.isNumber())
|
||||
@@ -19,7 +19,7 @@ pub fn fromJS(globalObject: *JSC.JSGlobalObject, value: JSValue) i64 {
|
||||
else if (value.isString()) brk: {
|
||||
var str = value.toBunString(globalObject) catch @panic("unreachable");
|
||||
defer str.deref();
|
||||
break :brk str.parseDate(globalObject);
|
||||
break :brk try str.parseDate(globalObject);
|
||||
} else return 0;
|
||||
|
||||
const unix_timestamp: i64 = @intFromFloat(double_value);
|
||||
|
||||
Reference in New Issue
Block a user