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

Problem with create and relartions #178

Closed
maxsosa opened this issue May 29, 2013 · 5 comments
Closed

Problem with create and relartions #178

maxsosa opened this issue May 29, 2013 · 5 comments
Labels

Comments

@maxsosa
Copy link

maxsosa commented May 29, 2013

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.

@dresende
Copy link
Owner

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

@dresende
Copy link
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).

@dresende
Copy link
Owner

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

@maxsosa
Copy link
Author

maxsosa commented May 29, 2013

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...

@dresende
Copy link
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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants