Support jsonb, idle_timeout, connection_timeout, max_lifetime timeouts in bun:sql. Add onopen and onclose callbacks. Fix missing "code" property appearing in errors. Add error codes for postgres. (#16045)

This commit is contained in:
Jarred Sumner
2024-12-30 13:25:01 -08:00
committed by GitHub
parent f0073bfa81
commit 76bfceae81
15 changed files with 1152 additions and 347 deletions

View File

@@ -90,6 +90,36 @@ extern "C" JSPropertyIterator* Bun__JSPropertyIterator__create(JSC::JSGlobalObje
return JSPropertyIterator::create(vm, array.releaseData());
}
// The only non-own property that we sometimes want to get is the code property.
extern "C" EncodedJSValue Bun__JSPropertyIterator__getCodeProperty(JSPropertyIterator* iter, JSC::JSGlobalObject* globalObject, JSC::JSObject* object)
{
if (UNLIKELY(!iter)) {
return {};
}
auto& vm = iter->vm;
auto scope = DECLARE_THROW_SCOPE(vm);
RETURN_IF_EXCEPTION(scope, {});
if (UNLIKELY(object->type() == JSC::ProxyObjectType)) {
return {};
}
auto& builtinNames = WebCore::builtinNames(vm);
PropertySlot slot(object, PropertySlot::InternalMethodType::VMInquiry, vm.ptr());
if (!object->getNonIndexPropertySlot(globalObject, builtinNames.codePublicName(), slot)) {
return {};
}
if (slot.isAccessor() || slot.isCustom()) {
return {};
}
RETURN_IF_EXCEPTION(scope, {});
return JSValue::encode(slot.getPureResult());
}
extern "C" size_t Bun__JSPropertyIterator__getLongestPropertyName(JSPropertyIterator* iter, JSC::JSGlobalObject* globalObject, JSC::JSObject* object)
{
size_t longest = 0;