Skip to content

Setter is not called when value is undefined #1892

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

Closed
lazdmx opened this issue Jan 23, 2014 · 4 comments
Closed

Setter is not called when value is undefined #1892

lazdmx opened this issue Jan 23, 2014 · 4 comments
Milestone

Comments

@lazdmx
Copy link

lazdmx commented Jan 23, 2014

Setters are not fired with undefined value assigned to path.

mongoose = require "mongoose"
Schema = mongoose.Schema

Person = new Schema
  name: String

Person.path( "name" ).set ( x ) ->
  console.log "called with value <#{x}> of type #{typeof x}"
  x

Person = mongoose.model "Person", Person


p = new Person( )
p.name = "John"
p.name = undefined

Output is:

called with value <John> of type string
@th0r
Copy link

th0r commented Mar 18, 2014

+1

@ripples-alive
Copy link

+1
It really bothers me a lot.

@fiznool
Copy link

fiznool commented Jun 8, 2015

Is there any chance this fix could be backported to the 3.8 branch?

@vkarpov15
Copy link
Collaborator

Not likely, this is something that's debateably backwards-breaking and I'm hesitant to put it into 3.8.x as a bug fix.

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

5 participants