Comments (9)
@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? 🙏
from feathers-sequelize.
@ekryski fair enough, let me go try it out and I'll re-open the issue if I can't get it to work?
from feathers-sequelize.
@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 customer
with a relational field of contactId
. And in customer/1
I do a PATCH
of
{ "contactId": 1 }
The error response I see is null value in column "contactId" violates not-null constraint
and also in the SQL query I see logged on the server there is no mention of this relational/reference field being updated.
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"
}
from feathers-sequelize.
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 messageId
in the above. Which is why I get this error:
SequelizeBaseError: null value in column "messageId" violates not-null constraint
from feathers-sequelize.
Oh oh oh, I think it's a bug introduced in the recent version.
I downgraded from: "feathers-sequelize": "^1.4.3"
to: "feathers-sequelize": "^1.4.0"
And not facing the same issue anymore.
from feathers-sequelize.
Interesting. Could you try at which version (1.4.1, 1.4.2 or 1.4.3) it breaks? Eventually the caret (^
) range should still install the latest version.
from feathers-sequelize.
sure, let me try 1.4.1 and 1.4.2 and get back to you
from feathers-sequelize.
I could get it to work with the version 1.4.3 as well.
The issue was with the relations written in the migration.
My apologies.
from feathers-sequelize.
@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.
from feathers-sequelize.
Related Issues (20)
- Unable to modify hook result of referenced models HOT 1
- app.service('users').get(message.userId, params) returns createdAt and updatedAt dates as string rather than Date object on SQLite
- How can I use a limit and a required in an include? HOT 9
- Support Deep Aware for JSON Objects on Patch HOT 1
- Query by Association HOT 5
- id is not set correctly to a non-null value when using multi-create and throws an error instead of creating
- Got 404 No Record Found while using include in before get hooks HOT 1
- Optimize multi patch when $returning is false. HOT 3
- Use proper $and in patch and remove methods HOT 2
- Use consistent $select in all methods, optimize select function HOT 2
- iLike method with accent. HOT 1
- how to set field to NULL on patch request?
- Allow join queries on remove
- Better handle paranoid models HOT 2
- Since version 6.4.0 getting "error: GeneralError: column "id" does not exist" HOT 1
- feathers-sequelize remove method rewrite breaking change when deleting multiple items without id in table
- Associations Suggestion
- Service .find() method return a wrong type (not paginated)
- feathers sequlize type confict when overwritting find and calling super.find HOT 1
- Support withSchema [with PR] HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feathers-sequelize.