Skip to content

Problem with create and relartions #178

Closed

Description

@maxsosa

Hello. I have the folowing situation:

model: Rol {id, description}
model: User {name, code, status} asociated with Rol (User hasMany Rol)

When I load the object User (that automatically fetch Rols) I have something like this:

User: {id: 1, name: "asdasd", code: "asdasd", status: 1, rols: [{id: 1, description: "rol 1"}]}

When I create a new object: User.create([model], function ....)

It generates an insert statement like this:

INSERT INTO user (code, name, status, rols) VALUES ('asdasd', 'asdasd', 0, (id = 2, descripcion = 'Supervisor'))

So the problem is that is trying to insert rols directly into thr user...

Im doing something wrong?

Thanks.

Activity

  1. dresende commented on May 29, 2013

    @dresende
    Owner

    It doesn't seem so. I have to test and see what's going wrong.

  2. dresende commented on May 29, 2013

    @dresende
    Owner

    I was re-reading your issue. Your trying to create a user with a roll directly defined in user object, right? You can't do this for now. It should behave as you're showing (it should ignore the rols key).

  3. dresende commented on May 29, 2013

    @dresende
    Owner

    I think that what you want is what is described in #162, right?

  4. maxsosa commented on May 29, 2013

    @maxsosa
    Author

    Well, I understand that the related objects have to be saved with setRols (in this case), but the problem is with the insert statement generated. It contains this field "rols" that is un the object, but not in the definition...

  5. dresende commented on May 29, 2013

    @dresende
    Owner

    Yes, that's the only thing I want to check and fix. The other thing I suppose it's the same as the other issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions