New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: coerce property value defined as array of ObjectID #582
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃憤 The fix looks reasonable. I left a comment about your note.
title: 'arrayOfObjectID', | ||
}); | ||
const found = await Article.findOne({where: {title: 'arrayOfObjectID'}}); | ||
found.xidArr.should.be.an.Array().which.containDeep([new ds.ObjectID(objectIDLikeString)]); | ||
// the type of the returned array is actually string even it's stored as ObjectIds in the db as expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the type of the returned array is actually string
@agnes512 Isn't the returned xidArr
in type objectId? From the test case, it's not string...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused too. I checked with found.xidArr[0].should.be.an.instanceOf(ds.ObjectID)
, and it fails, while the xid
test case in L129 is an objectId. I couldn't find where the array ges converted though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know what's the typeof found.xidArr[0]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String!
@slnode test please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃憤 LGTM
]); | ||
// check if the array is stored in ObjectId | ||
const raw = await findRawModelDataAsync('ArticleC', found[0].id); | ||
raw.xidArr[0].should.be.an.instanceOf(ds.ObjectID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃憤
Fixes loopbackio/loopback-next#5848 : failed to set array of strings to ObjectId with
dataType: objectid
.Checklist
馃憠 Read and sign the CLA (Contributor License Agreement) 馃憟
npm test
passes on your machine