-
Notifications
You must be signed in to change notification settings - Fork 74
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
Relation between Models not working. #98
Comments
@zusamann if you are just getting started I would use the new generator as mentioned here: #20 (comment). It sets them up correctly for you now 😄 . The feathers-demos repos are starting to become stale and are in need of some TLC with all the updates that have gone into the Auk release. If that works for you can we close this? 🙏 |
@ekryski fair enough, let me go try it out and I'll re-open the issue if I can't get it to work? |
@ekryski I have tried it with feathers-cli and I am able to reproduce the error. For further verification I did another test where I used models and migrations written in the official example by sequelize for express. What is happening is the data I send in the query for the relational field. It's somehow not getting processed and being set to null. I have noticed this in all my tests. So let's say I have a { "contactId": 1 } The error response I see is Could it be a bug recently introduced? Using the following versions right now, must all be latest: {
"feathers": "^2.1.1",
"feathers-hooks": "^1.8.1",
"feathers-rest": "^1.7.1",
"feathers-sequelize": "^1.4.3",
"nodemon": "^1.11.0",
"pg": "^6.1.5",
"pg-hstore": "^2.3.2",
"sequelize": "^3.30.2"
} |
I have updated my sample repo here to showcase the exact same issue. I have two resources here, a Channel and a Message, and just for this example I have only one message in each channel. Now I'm able to create messages no problem. // POST /messages { "text": "Hola!" }
{
"createdAt": "2017-03-24T14:00:26.577Z",
"updatedAt": "2017-03-24T14:00:26.577Z",
"id": 1,
"text": "Hola!",
"ChannelId": null
} Which is all good, but when I now try creating a new channel like so: // POST localhost:3003/channels { "name": "hoo hoo lalala", "messageId": 1 } Here is the SQL query that runs INSERT INTO "Channel" ("id","name","createdAt","updatedAt") VALUES (DEFAULT,'hoo hoo lalala','2017-03-24 14:00:26.587 +00:00','2017-03-24 14:00:26.587 +00:00') RETURNING *; As you can see, no mention of |
Oh oh oh, I think it's a bug introduced in the recent version. I downgraded from: And not facing the same issue anymore. |
Interesting. Could you try at which version (1.4.1, 1.4.2 or 1.4.3) it breaks? Eventually the caret ( |
sure, let me try 1.4.1 and 1.4.2 and get back to you |
I could get it to work with the version 1.4.3 as well. My apologies. |
@zusamann Can you give some examples of the problems with your relations? I'm encountering a similar issue and understanding the model problems could help me too. |
Have been trying to follow the demo given here
many-to-many-sequelize
by @ekryski. But to no avail ☹...I have two models:
I am able to create both resources independently, but not able to associate a given
message
to achannel
. Here I want any onemessage
to be linked to anychannel
. All queries being made to thechannel
just ignore the data and do not modify any relational fields, which btw do not even appear in the resource on theget
call.I'm not sure where the error lies. Maybe in the
migrations
? But they were not documented in the demo above so not sure if I've written them correctly or not.Have uploaded my entire code here:
feathers-sequelize-poc
for further evaluation by everyone.The text was updated successfully, but these errors were encountered: