"Failed lookup of model or field during internal processing. This means that the internal representation was mutated incorrectly."
See original GitHub issueA schema that used to work before (preview 21) does not work in preview 22 any more for generation:
datasource db {
provider = "mysql"
// other options are: "mysql" and "sqlite"
url = "mysql://user:pass@localhost:3306/asd_nest_prisma"
}
generator client {
provider = "prisma-client-js"
}
//generator typegraphql {
// provider = "node_modules/typegraphql-prisma/generator.js"
// output = "../prisma/generated/type-graphql"
//}
model User {
email String @unique
id Int @default(autoincrement()) @id
mollieApiKey String?
name String
passwordHash String?
phone String?
locations Location[] @relation(name: "userLocations")
services Service[] @relation(name: "userServices", references: owner)
assignedServices Service[] @relation(name: "assignedServices", references: assignee)
contacts Contact[] @relation(name: "userContacts")
contactsAsTarget Contact[] @relation(name: "targetUsers")
shop Shop? @relation("userShop")
suppliers Supplier[]
tokens UserToken[]
}
model UserToken {
id Int @default(autoincrement()) @id
randomHex String @unique
user User?
@@index([user])
}
model Contact {
id Int @default(autoincrement()) @id
showShares Int
owner User @relation(name: "userContacts")
target User? @relation(name: "targetUsers")
@@index([target])
//@@unique([owner, target])
}
model Location {
description String
id Int @default(autoincrement()) @id
name String
sku String?
user User? @relation(name: "userLocations")
@@index([user])
}
model Order {
customerEmail String
customerName String
dueDeposit Float @default(0)
dueTotal Float
id Int @default(autoincrement()) @id
priceJson String
shop Shop?
payments Payment[]
@@index([shop])
}
model Payment {
deposit Int @default(0)
id Int @default(autoincrement()) @id
metadata String
method String @default("mollie")
status String @default("pending")
total Float?
order Order?
@@index([order])
}
model Place {
id Int @default(autoincrement()) @id
name String
products Product[] @relation(references: [placeId])
}
model Price {
dateGeq DateTime?
dateLeq DateTime?
id Int @default(autoincrement()) @id
name String
price Float
priceDeposit Float @default(0)
pricePerPerson Int @default(0)
seats Int?
timeGeq DateTime?
timeLeq DateTime?
product Product?
@@index([product])
}
model Product {
description String?
extraString String?
id Int @default(autoincrement()) @id
name String
requiresExtra Int @default(0)
requiresFlightArrival Int @default(0)
requiresFlightDeparture Int @default(0)
requiresName Int @default(1)
place Place
shop Shop?
prices Price[]
@@index([place])
@@index([shop])
}
model Service {
canceled Int @default(0)
changed Int @default(0)
clientEmail String?
cost Float?
datetime DateTime
description String?
id Int @default(autoincrement()) @id
notCashed Float
notes String?
paid Float?
preview String
shared Int @default(0)
toPay Float
assignee User? @relation(name: "assignedServices", references: id)
owner User @relation(name: "userServices", references: id)
sourceService Service? @relation("serviceToservice")
services Service[] @relation("serviceToservice")
supplierIn Supplier? @relation(name: "suppliedInServices", references: id)
supplierOut Supplier? @relation(name: "suppliedOutServices", references: id)
vehicle Vehicle?
contacts Contact[]
@@index([vehicle])
@@index([sourceService])
@@index([owner])
@@index([supplierOut])
@@index([assignee])
@@index([supplierIn])
}
model Shop {
id Int @default(autoincrement()) @id
name String
prefix String
owner User @relation("userShop")
orders Order[]
products Product[]
}
model Supplier {
id Int @default(autoincrement()) @id
name String?
vat String?
owner User
servicesSuppliedIn Service[] @relation(name: "suppliedInServices", references: supplierIn)
servicesSuppliedOut Service[] @relation(name: "suppliedOutServices", references: supplierOut)
@@index([owner])
}
model Vehicle {
id Int @default(autoincrement()) @id
name String
owner User
services Service[]
@@index([owner])
}
The error you get on generate and validate:
C:\Users\Jan\Documents\throwaway\matt>npx prisma2@alpha validate
Error: Schema parsing
thread 'main' panicked at 'Failed lookup of model or field during internal processing. This means that the internal representation was mutated incorrectly.', src\libcore\option.rs:1188:5
stack backtrace:
0: backtrace::backtrace::dbghelp::trace
at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.40\src\backtrace/dbghelp.rs:88
1: backtrace::backtrace::trace_unsynchronized
at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.40\src\backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src\libstd\sys_common/backtrace.rs:84
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src\libstd\sys_common/backtrace.rs:61
4: core::fmt::write
at src\libcore\fmt/mod.rs:1025
5: std::io::Write::write_fmt
at src\libstd\io/mod.rs:1426
6: std::sys_common::backtrace::_print
at src\libstd\sys_common/backtrace.rs:65
7: std::sys_common::backtrace::print
at src\libstd\sys_common/backtrace.rs:50
8: std::panicking::default_hook::{{closure}}
at src\libstd/panicking.rs:193
9: std::panicking::default_hook
at src\libstd/panicking.rs:210
10: std::panicking::rust_panic_with_hook
at src\libstd/panicking.rs:471
11: rust_begin_unwind
at src\libstd/panicking.rs:375
12: core::panicking::panic_fmt
at src\libcore/panicking.rs:84
13: core::option::expect_failed
at src\libcore/option.rs:1188
14: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
15: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
16: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
17: datamodel::validator::standardise::Standardiser::get_datasource_fields_for_relation_field
18: datamodel::validator::standardise::Standardiser::standardise
19: datamodel::validator::validation_pipeline::ValidationPipeline::validate
20: datamodel::parse_datamodel_internal
21: datamodel::parse_datamodel
22: <core::result::Result<core::option::Option<T>,prisma::error::PrismaError> as prisma::data_model_loader::PrismaResultOption<T>>::inner_map
23: prisma::data_model_loader::load_data_model_components
24: prisma::cli::CliCommand::dmmf
25: prisma::main::{{closure}}
26: <std::future::GenFuture<T> as core::future::future::Future>::poll
27: tokio::runtime::enter::Enter::block_on
28: tokio::runtime::thread_pool::ThreadPool::block_on
29: tokio::runtime::context::enter
30: tokio::runtime::Runtime::block_on
31: prisma::main
32: std::rt::lang_start::{{closure}}
33: std::rt::lang_start_internal::{{closure}}
at src\libstd/rt.rs:52
34: std::panicking::try::do_call
at src\libstd/panicking.rs:292
35: __rust_maybe_catch_panic
at src\libpanic_unwind/lib.rs:78
36: std::panicking::try
at src\libstd/panicking.rs:270
37: std::panic::catch_unwind
at src\libstd/panic.rs:394
38: std::rt::lang_start_internal
at src\libstd/rt.rs:51
39: main
40: _tmainCRTStartup
41: mainCRTStartup
42: sqlite3GenerateConstraintChecks
43: sqlite3GenerateConstraintChecks
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
VS Code doesn't indicate errors when wrong field references are ...
This mea ns that the internal representation was mutated incorrectly. ... 'main' panicked at 'Failed lookup of model or field during internal processing....
Read more >C Users Home OneDrive Graphql examples gt yarn prisma2 dev y ...
... 'main' panicked at 'Failed lookup of model or field during internal processing. This means that the internal representation was mutated incorrectly.
Read more >Don't let dicts spoil your code - Roman Imankulov
In -place mutations may have different names: pre-processing, populating, enriching, data massage, etc. The result is the same.
Read more >Handling GraphQL errors like a champ with unions and ...
Error handling can be frustrating in GraphQL. This post shows you how to use unions and interfaces to handle errors in a more...
Read more >Chapter 12: DNA Damage and Repair – Chemistry
Mutations can occur for many reasons. For example, DNA mutations can be caused by mistakes made by the DNA polymerase during replication. As...
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 Free
Top 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

This shows mostly differences in the
@defaultand thenameof@@index- someone else will look deeper into this later and try to understand what is going on. We’ll keep you updated.