Fix complex Record IDs from being output incorrectly within JavaScript functions (#4661)

This commit is contained in:
Tobie Morgan Hitchcock 2024-09-02 10:19:25 +01:00 committed by GitHub
parent a0028e2c7a
commit 1153a2469b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -21,6 +21,7 @@ impl Record {
Value::Array(v) => v.into(),
Value::Object(v) => v.into(),
Value::Number(v) => v.into(),
Value::Uuid(v) => v.into(),
v => v.as_string().into(),
},
},
@ -33,8 +34,8 @@ impl Record {
}
#[qjs(get)]
pub fn id(&self) -> String {
self.value.id.to_raw()
pub fn id(&self) -> Value {
self.value.id.clone().into()
}
// Compare two Record instances
pub fn is(a: &Record, b: &Record) -> bool {

View file

@ -150,6 +150,12 @@ async fn script_function_types() -> Result<(), Error> {
manager = function() {
return new Record('user', 'joanna');
},
organisation = function() {
return new Record('organisation', {
alias: 'acme',
name: 'Acme Inc',
});
},
identifier = function() {
return new Uuid('03412258-988f-47cd-82db-549902cdaffe');
}
@ -168,6 +174,7 @@ async fn script_function_types() -> Result<(), Error> {
created_at: d'1995-12-17T03:24:00Z',
next_signin: 1w2d6h,
manager: user:joanna,
organisation: organisation:{ alias: 'acme', name: 'Acme Inc' },
identifier: u'03412258-988f-47cd-82db-549902cdaffe',
}
]",