-
-
Notifications
You must be signed in to change notification settings - Fork 364
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] TypeMismatch error when attribute is called 'model' #1023
Comments
@gmaragao I don't see this being addressed anytime soon. This will require a strong line by line assessment of the project to determine what we need to do here. I don't think this will happen anytime soon. If you would like to attempt to put up a PR for this, that'd be awesome. |
Just adding some debugging This throws the invalid error from within Of the available schema entries, I get this thrown on the following set: When validating item Related Issues |
As @gmaragao indicated, I think the problem is related with the name of the attribute, The following code in Object.defineProperty(this, "model", {
"configurable": false,
"value": model
}); In a simple test case, derived from this stack overflow question, this is how the And after the execution of the aforementioned code: This code is executed when processing the const array: any = (await Promise.all(result.Items.map(async (item) => await new this.internalSettings.model.Document(item, {"type": "fromDynamo"}).conformToSchema({"customTypesDynamo": true, "checkExpiredItem": true, "saveUnknown": true, "modifiers": ["get"], "type": "fromDynamo"})))).filter((a) => Boolean(a)); The reported error is a consequence of that change when the type of the returned const {isValidType, matchedTypeDetails, typeDetailsArray} = utils.dynamoose.getValueTypeCheckResult(schema, value, genericKey, settings, {"standardKey": true, typeIndexOptionMap});
if (!isValidType) {
throw new Error.TypeMismatch(`Expected ${key} to be of type ${typeDetailsArray.map((detail) => detail.dynamicName ? detail.dynamicName() : detail.name.toLowerCase()).join(", ")}, instead found type ${typeof value}.`);
... I do not see a clear solution, as I assume this property is heavily used in the context of the |
This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 3 days. |
Any feedback on that topic? Please, can I help you in any way? |
@jccampanero No updates on this. As I said above, I don't see this being addressed anytime soon. If you want, feel free to work towards creating a PR. But I'm not sure I'll be able to find time to look into this anytime soon. |
Also running into this issue. I've had to rename my column from model to modelName. It works, but it's not ideal since now I'm changing my schema to accommodate this bug. Additionally, if I don't include Would love to see this addressed in a future version! Thanks! |
… TypeMismatch errors closes #1023
I am very happy to see that the issue is solved in the new version of the library @fishcharlie. I am sorry for hadn't been of more help in the resolution of the issue. Please, don't hesitate to contact me if you think I could contribute to the project in some way, I will be glad to help. |
@jccampanero Testing v3 alpha versions (and hopefully soon beta) versions and providing feedback (positive or negative) would be incredibly helpful at this point 😃 |
Sure @fishcharlie, I will try testing the new version. |
@jccampanero is it working for you?
|
@nimit2801 I am very sorry to say, but honestly I haven't tested the new functionally yet. May I ask why? Does the problem also occur in the new version of the library? |
I'm actually using |
Summary:
When trying to create an item using a schema, dynamoose triggers a TypeMismatch error when using an attribute called 'model'. It works fine with any other attribute name.
Code sample:
Schema
Model
General
index.js
Current output and behavior (including stack trace):
TypeMismatch: Expected model to be of type array, instead found type object.
at checkTypeFunction (...\node_modules\dynamoose\lib\Document.ts:302:11)
at Array.map ()
at Function. (...\node_modules\dynamoose\lib\Document.ts:323:111)
at Generator.next ()
at fulfilled (...\node_modules\dynamoose\dist\Document.js:5:58)
Expected output and behavior:
Output behavior when using the attribute as 'model1'
Environment:
Operating System: Windows
Operating System Version: Windows 10 Enterprise
Node.js version (
v12.18.2
):NPM version: (
6.14.5
):Dynamoose version: 2.3.0
Other information (if applicable):
Other:
The text was updated successfully, but these errors were encountered: