Error for foreign key violation is very undescriptive
See original GitHub issueDescriotion
I have an old database. There are foreign key violations. Since basically all tables are interconnected, I cannot load any table from the studio. I would like to use a studio or some other tool to fix the database.
Problem
Error in Prisma Client request:
Error: Failed to validate the query `Error occurred during query validation & transformation:
Query (object)
↳ findManyadresy (field)
↳ take (argument)
↳ Argument does not exist on enclosing type.` at `.Query.findManyadresy.take`
at PrismaClientFetcher.request (C:\Users\akxe\AppData\Roaming\Prisma\Studio\-Users-akxe-Documents-Programming-rita\runtime\index.js:1:228283)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async C:\Users\akxe\Documents\Programming\rita\node_modules\@prisma\cli\build\index.js:2:1616391
at async Photon.request (C:\Users\akxe\Documents\Programming\rita\node_modules\@prisma\cli\build\index.js:2:1616874)
at async PhotonService.respond (C:\Users\akxe\Documents\Programming\rita\node_modules\@prisma\cli\build\index.js:2:868721)
at async WebSocket.StudioServer.onWSMessage (C:\Users\akxe\Documents\Programming\rita\node_modules\@prisma\cli\build\index.js:2:774591)
This error is not very much helpful. It does not provide anything to go reason about.
Suggested solution
How about an error:
Error in Prisma Client request:
Error: Failed to validate the query `Row for column "fieldName" of table "tableName" was not present for value(s): 1,2,3,4,5,6... and X more.`
Alternatives
You pick one, there will be many
Additional context
Prisma 2.6.0, applies to 2.7.0, the same (waiting for nexus-plugin-prisma
to upgrade)
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
Error 546 - Sybase Infocenter
Foreign key constraint violation occurred, dbname = '%. ... For example, error 546 can be raised when Adaptive Server detects that the data...
Read more >Get error foreign key violation - Stack Overflow
I have tried to find solutions here and have implemented like delete parent tables (user, in my case), and create that table again...
Read more >Foreign key violation when trying to insert into a table [closed]
I am trying to insert value 15 to ID of A but a FK violation occurs. error is similar to given below: ERROR...
Read more >Foreign key violation error when starting flow with de ... - GitHub
Description When trying to submit a flow run without registered agent (i removed agent via ui) (but agent was still running though), prefect...
Read more >3 common foreign key mistakes (and how to avoid them)
Foreign key constraints are important to any SQL database, but they can also cause problems if they're not implemented correctly.
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
Indeed, the error from studio is very generic…
I can, but I am now at vacation and will return on a week. You should have all necessary in here. I’ll do it in a week if it is still needed.
Well… I know for sure, that none of “Adresy” is invalid in “Firmy”, but I am almost 100% confident, the others do have invalid foreign keys.
EDIT: The SQL
SELECT * FROM firmy WHERE NOT EXISTS (SELECT idFirmy FROM adresy);
produces 0 rows.I have also tested relations:
firmy_adresy_idFirmyTofirmy
firmy_adresyTofirmy_idFirAdr
firmy_adresyTofirmy_idKorespAdr
firmy_adresyTofirmy_idLepicAdr
None of them produces any row(s).