Skip to content
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

'path' field in subelement causes exception #1245

Closed
bratchenko opened this issue Dec 11, 2012 · 3 comments
Closed

'path' field in subelement causes exception #1245

bratchenko opened this issue Dec 11, 2012 · 3 comments

Comments

@bratchenko
Copy link
Contributor

After update to version 3.5.0 i got an error, which is caused by field named path in one of my models' subelement.

Here is sample code, producing error:

mongoose    = require 'mongoose'
subScm = mongoose.Schema(
    path: String
)
Scm = mongoose.Schema(
    els: [subScm]
)

I get:

TypeError: Object #<Object> has no method '_markModified'
    at EmbeddedDocument.markModified (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/types/embedded.js:63:24)
    at EmbeddedDocument.Document._set (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/document.js:553:10)
    at EmbeddedDocument.Document.set (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/document.js:495:10)
    at EmbeddedDocument.Object.defineProperty.set [as path] (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/document.js:1125:45)
    at DocumentArray.SchemaArray (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/schema/array.js:49:22)
    at new DocumentArray (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/schema/documentarray.js:45:13)
    at Function.Schema.interpretAsType (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/schema.js:320:14)
    at Schema.path (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/schema.js:286:29)
    at Schema.add (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/schema.js:204:12)
    at new Schema (/Users/daeq/workspace/onvidb/node_modules/mongoose/lib/schema.js:70:10)

This error didn't exist in version 3.4.0. So I think it was introduced in one of latest commits.

I'll try to figure it out and propose patch, but maybe you could do it faster.

aheckmann added a commit that referenced this issue Dec 11, 2012
@aheckmann
Copy link
Collaborator

@daeq I'm actually having trouble reproducing this now. I don't want to rollback the commit though unless I know definitively. Do you have any more information to reproduce?

@bratchenko
Copy link
Contributor Author

I create file test.js with this contents:

var mongoose = require('mongoose');
var EmbeddedScm = mongoose.Schema({
    path: String
});
var Scm = mongoose.Schema({
    subElements: [EmbeddedScm]
});

Then:

npm install git://github.com/LearnBoost/mongoose#20f6fbebdcaa6f75e9cc4329e3e667cde881cd6e
node test.js

I get:

TypeError: Object #<Object> has no method '_markModified'
    at EmbeddedDocument.markModified (/Users/daeq/node_modules/mongoose/lib/types/embedded.js:63:24)
    at EmbeddedDocument.Document._set (/Users/daeq/node_modules/mongoose/lib/document.js:553:10)
    at EmbeddedDocument.Document.set (/Users/daeq/node_modules/mongoose/lib/document.js:495:10)
    at EmbeddedDocument.Object.defineProperty.set [as path] (/Users/daeq/node_modules/mongoose/lib/document.js:1125:45)
    at DocumentArray.SchemaArray (/Users/daeq/node_modules/mongoose/lib/schema/array.js:49:22)
    at new DocumentArray (/Users/daeq/node_modules/mongoose/lib/schema/documentarray.js:45:13)
    at Function.Schema.interpretAsType (/Users/daeq/node_modules/mongoose/lib/schema.js:320:14)
    at Schema.path (/Users/daeq/node_modules/mongoose/lib/schema.js:286:29)
    at Schema.add (/Users/daeq/node_modules/mongoose/lib/schema.js:204:12)
    at new Schema (/Users/daeq/node_modules/mongoose/lib/schema.js:70:10)

Node.js version is 0.8.8

When i install mongoose from git://github.com/LearnBoost/mongoose#master error doesn't reproduce.

@aheckmann
Copy link
Collaborator

ok got it. thanks!

aheckmann added a commit that referenced this issue Dec 12, 2012
aheckmann added a commit that referenced this issue Dec 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants