Error when directly setting foreign key and using connect syntax
See original GitHub issueBug description
Cannot directly set a foreign key for a relation and use the connect syntax to connect another relation.
First mentioned here: #5788
How to reproduce
Use the client in this way:
await database.user.create({
data: {
organisationId: "1234",
rooms: {
connect: [{id: "5678"}, {id: "9012"}]
}
}
})
Expected behavior
No Typescript errors
Prisma information
Environment & setup
- OS: Arch Linux
- Database: PostgreSQL
- Node.js version: 17.3.0
Prisma Version
prisma : 3.8.0-dev.40
@prisma/client : 3.8.0-dev.40
Current platform : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 367f1321e79a7ba33fcac73ed17111312b87e526 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine : migration-engine-cli 367f1321e79a7ba33fcac73ed17111312b87e526 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 367f1321e79a7ba33fcac73ed17111312b87e526 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 367f1321e79a7ba33fcac73ed17111312b87e526 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 367f1321e79a7ba33fcac73ed17111312b87e526
Studio : 0.449.0
Preview Features : fullTextSearch
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
3 common foreign key mistakes (and how to avoid them)
Dangling foreign keys 3. Not creating foreign key indexes Bonus: Not using foreign keys Key takeaway: think before you CREATE TABLE.
Read more >MySQL Error Code 1215: "Cannot add foreign key constraint"
How to diagnose: Use SHOW CREATE TABLE parent to check that the local column and the referenced column both have the same data...
Read more >Syntax error 1064 (42000) when adding foreign key in SQL
First, I added a foreign key to table "Room" so that column roomtype was referencing table Roomtype, column ID. ALTER TABLE room ADD...
Read more >13.1.17.5 FOREIGN KEY Constraints - MySQL :: Developer Zone
Adding Foreign Key Constraints ... The foreign key can be self referential (referring to the same table). When you add a foreign key...
Read more >An Essential Guide to MySQL Foreign Key By Practical ...
Finally, specify how foreign key maintains the referential integrity between the child and parent tables by using the ON DELETE and ON UPDATE...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sourdzl Nope