updateAttributes not working properly on Mongoose #35

Closed
nesterko opened this Issue Feb 19, 2012 · 2 comments

Comments

Projects
None yet
2 participants
@nesterko

There was an issue before about Boolean type not updating properly. In addition to that, even String type does not update consistently.

For example, we want to update one field F1. It is not updated unless in addition to F1 we make a dummy change to at least one another field (for example, F2). For some fields such trick is not necessary, for some you need it.

I am having trouble determining what is the reason behind this kind of behavior. Would be great if you could shed some light on this.

All fields are String, database is Mongoose. Thank you.

@1602

This comment has been minimized.

Show comment Hide comment
@1602

1602 Feb 20, 2012

Owner

Could you please show some isolated test case?

On Mon, Feb 20, 2012 at 1:49 AM, nesterko <
reply@reply.github.com

wrote:

There was an issue before about Boolean type not updating properly. In
addition to that, even String type does not update consistently.

For example, we want to update one field F1. It is not updated unless in
addition to F1 we make a dummy change to at least one another field (for
example, F2). For some fields such trick is not necessary, for some you
need it.

I am having trouble determining what is the reason behind this kind of
behavior. Would be great if you could shed some light on this.

All fields are String, database is Mongoose. Thank you.


Reply to this email directly or view it on GitHub:
#35

Thanks,
Anatoliy Chakkaev

Owner

1602 commented Feb 20, 2012

Could you please show some isolated test case?

On Mon, Feb 20, 2012 at 1:49 AM, nesterko <
reply@reply.github.com

wrote:

There was an issue before about Boolean type not updating properly. In
addition to that, even String type does not update consistently.

For example, we want to update one field F1. It is not updated unless in
addition to F1 we make a dummy change to at least one another field (for
example, F2). For some fields such trick is not necessary, for some you
need it.

I am having trouble determining what is the reason behind this kind of
behavior. Would be great if you could shed some light on this.

All fields are String, database is Mongoose. Thank you.


Reply to this email directly or view it on GitHub:
#35

Thanks,
Anatoliy Chakkaev

@nesterko

This comment has been minimized.

Show comment Hide comment
@nesterko

nesterko Feb 20, 2012

Alright, here are the main ingredients:

Model declaration:
Privilege = describe 'Privilege', () ->
property 'slug', String, index : true
property 'name', String
property 'activated', String, default: "no"

update inside a controller:
action 'update', ->
@privilege.updateAttributes body, (err) =>
if !err
flash 'info', 'Privilege updated'
redirect path_to.admin_privilege(@Privilege)
else
flash 'error', 'Privilege can not be updated'
@title = 'Edit privilege details'
render 'edit'

_form.jade partial within views:
.clearfix
!= form.label("name")
.input
!= form.input("name")
!= form.label("slug")
.input
!= form.input("slug")
!= form.label("activated")
.input
- if (privilege.activated === "yes")
input(type="checkbox", name="activated", value="yes", checked)
- else
input(type="checkbox", name="activated", value="yes")

The only field that has trouble updating under this setup is 'activated', to update it I need to change say 'name' together with it. Changing just 'activated' does not do the trick.

This setup works fine under driver : memory.

Please let me know if you need more info.

Alright, here are the main ingredients:

Model declaration:
Privilege = describe 'Privilege', () ->
property 'slug', String, index : true
property 'name', String
property 'activated', String, default: "no"

update inside a controller:
action 'update', ->
@privilege.updateAttributes body, (err) =>
if !err
flash 'info', 'Privilege updated'
redirect path_to.admin_privilege(@Privilege)
else
flash 'error', 'Privilege can not be updated'
@title = 'Edit privilege details'
render 'edit'

_form.jade partial within views:
.clearfix
!= form.label("name")
.input
!= form.input("name")
!= form.label("slug")
.input
!= form.input("slug")
!= form.label("activated")
.input
- if (privilege.activated === "yes")
input(type="checkbox", name="activated", value="yes", checked)
- else
input(type="checkbox", name="activated", value="yes")

The only field that has trouble updating under this setup is 'activated', to update it I need to change say 'name' together with it. Changing just 'activated' does not do the trick.

This setup works fine under driver : memory.

Please let me know if you need more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment