vidigami / backbone-rest

A RESTful controller for BackboneORM
http://vidigami.github.io/backbone-orm/backbone-rest.html
MIT License
7 stars 3 forks source link

Issue with DELETE #10

Open ghost opened 10 years ago

ghost commented 10 years ago

Hi guys

I noticed the latest implementation is getting errors handling DELETE requests after upgrading recently.

Here are the relevant versions from package.json :

OLD WORKING

"backbone": "~1.1.2", "backbone-rest": "~0.5.7", "backbone-orm": "~0.5.15",

NEW BROKEN

"backbone": "^1.1.2", "backbone-orm": "^0.7.0", "backbone-rest": "^0.7.2",

Here is the error that Im seeing ...

Error 500 from DELETE /api/tag/51: TypeError: Object #<Schema> has no method 'idType' at Function.module.exports.JSONUtils.parseField (/app/node_modules/backbone-rest/node_modules/backbone-orm/backbone-orm.js:1007:52) at RESTController.module.exports.RESTController.requestId (/app/node_modules/backbone-rest/lib/rest_controller.js:51:24) at RESTController.module.exports.RESTController.destroy (/app/node_modules/backbone-rest/lib/rest_controller.js:220:42) at /app/node_modules/backbone-rest/lib/lib/json_controller.js:88:23 at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:76:5) at next (/app/node_modules/express/lib/router/route.js:100:13) at RESTController.module.exports.JSONController._setHeaders (/app/node_modules/backbone-rest/lib/lib/json_controller.js:115:14) at /app/node_modules/backbone-rest/lib/lib/json_controller.js:11:61 at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:76:5) at next (/app/node_modules/express/lib/router/route.js:100:13)

Thanks for your work - REST/ORM all in one, brilliant!

kmalakoff commented 10 years ago

We're glad you are enjoying it. Sorry about this problem...

I've looked at 0.7.0 and it seems to have typeId defined in schema. Can you try upgrading BackboneORM to 0.7.1 and see if the issue still happens?

If so, I might need you put together a test case.

ghost commented 10 years ago

I can confirm that this is still happening for me when I upgrade to 0.7.1

So Backbone dependencies are :

"backbone": "~1.1.2", "backbone-orm": "~0.7.1", "backbone-rest": "~0.7.2",

Error message is same but - obviously - line numbers are different :

Error 500 from DELETE /api/tag/44: TypeError: Object #<Schema> has no method 'idType' at Function.module.exports.JSONUtils.parseField (D:\dev\src\heroku\tcapp\node_modules\backbone-orm\backbone-orm.js:1002:52) at RESTController.module.exports.RESTController.requestId (D:\dev\src\heroku\tcapp\node_modules\backbone-rest\lib\rest_controller.js:51:24) at RESTController.module.exports.RESTController.destroy (D:\dev\src\heroku\tcapp\node_modules\backbone-rest\lib\rest_controller.js:220:42) at D:\dev\src\heroku\tcapp\node_modules\backbone-rest\lib\lib\json_controller.js:88:23 at Layer.handle [as handle_request] (D:\dev\src\heroku\tcapp\node_modules\express\lib\router\layer.js:76:5) at next (D:\dev\src\heroku\tcapp\node_modules\express\lib\router\route.js:100:13) at RESTController.module.exports.JSONController._setHeaders (D:\dev\src\heroku\tcapp\node_modules\backbone-rest\lib\lib\json_controller.js:115:14) at D:\dev\src\heroku\tcapp\node_modules\backbone-rest\lib\lib\json_controller.js:11:61 at Layer.handle [as handle_request] (D:\dev\src\heroku\tcapp\node_modules\express\lib\router\layer.js:76:5) at next (D:\dev\src\heroku\tcapp\node_modules\express\lib\router\route.js:100:13)

I'll try to prioritise some time to dig a bit deeper, but quite happy with older release so don't feel an urgent need to upgrade .

kmalakoff commented 10 years ago

Odd. We have tests for destroy and the function looks to exist.

Would you be able to send me your model (or at least a simplified version if it is confidential) and your rest controller parameters so I can try to replicate the problem?

kmalakoff commented 10 years ago

I've discussed with a colleague and we think it might be a deduping problem or an install problem.

Do you have have multiple copies of BackboneORM installed (for example, in global node_modules or some of your dependencies are still referring to 0.5.x so there are multiple copies in your application's node_models). Also, you could try npm cache clear -g and try a clean install.

Let me know if this is the case, otherwise, my colleague was suggesting you share your application with me on Dropbox, zip it up, etc. Not sure if it is confidential so might not be an options.