Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Multiple self relations make lift save panic #164

Closed
divyenduz opened this issue Oct 9, 2019 · 4 comments
Closed

Multiple self relations make lift save panic #164

divyenduz opened this issue Oct 9, 2019 · 4 comments
Assignees
Labels
bug/0-needs-info More information is needed for reproduction. kind/bug A reported bug.
Milestone

Comments

@divyenduz
Copy link

divyendusingh [p2-ambi]$ prisma2 --version
prisma2@2.0.0-preview013.3, binary version: 2b78c35cf302bf80ae5aaa863c5eee0d09541f83

Database: SQLite3

model User {
  id    String  @default(cuid()) @id @unique
  email String  @unique
  name  String?
  posts Post[]
  created User @relation(name: "createdByUserId")
  createdBy User @relation(name: "createdByUserId")

  updated User @relation(name: "updatedByUserId")
  updatedBy User @relation(name: "updatedByUserId")
}

model Post {
  id        String   @default(cuid()) @id @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  published Boolean
  title     String
  content   String?
  author    User?
}

Run prisma2 lift save --name init

Error:

 ERROR  Oops, an unexpected error occured!
Error in migration engine: [migration-engine/connectors/sql-migration-connector/src/sql_migration_persistence.rs:40] &sq
l_str = "CREATE TABLE IF NOT EXISTS \"lift\".\"_Migration\" (\"revision\" INTEGER NOT NULL PRIMARY KEY, \"name\" TEXT NO
T NULL, \"datamodel\" TEXT NOT NULL, \"status\" TEXT NOT NULL, \"applied\" INTEGER NOT NULL, \"rolled_back\" INTEGER NOT
 NULL, \"datamodel_steps\" TEXT NOT NULL, \"database_migration\" TEXT NOT NULL, \"errors\" TEXT NOT NULL, \"started_at\"
 DATE NOT NULL, \"finished_at\" DATE);"
thread 'tokio-runtime-worker-0' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorCollection { errors: [Mod
elValidationError { message: "Ambiguous self relation detected.", model_name: "User", span: Span { start: 131, end: 145
} }] }', src/libcore/result.rs:1084:5
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: migration_engine::main::{{closure}}
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::continue_panic_fmt
   5: rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::result::unwrap_failed
   8: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
   9: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  10: <sql_migration_connector::sql_migration_persistence::SqlMigrationPersistence as migration_connector::migration_per
sistence::MigrationPersistence>::load_all
  11: <migration_engine::commands::list_migrations::ListMigrationStepsCommand as migration_engine::commands::command
@divyenduz divyenduz added bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug. process/candidate Candidate for next Milestone. labels Oct 9, 2019
@janpio janpio added this to the Preview 15 milestone Oct 11, 2019
@janpio janpio removed the process/candidate Candidate for next Milestone. label Oct 11, 2019
@tomhoule
Copy link
Contributor

I tried lift with this schema and SQLite in the latest preview (prisma2@2.0.0-preview014.1, binary version: 188a379c9b8c6650e5812f9bdb7407d7b197692f) and I couldn't reproduce the bug. Can you still reproduce it?

@janpio janpio changed the title Multiple self relations make lift save panic Multiple self relations make lift save panic Oct 16, 2019
@tomhoule
Copy link
Contributor

I just tried reproducing the bug again with the version from the issue description (prisma2@2.0.0-preview013.3, binary version: 2b78c35cf302bf80ae5aaa863c5eee0d09541f83), both SQLite and MySQL, and I can't reproduce the crash.

@divyenduz divyenduz added bug/1-repro-available A reproduction exists and needs to be confirmed. and removed bug/2-confirmed We have confirmed that this is a bug. labels Oct 17, 2019
@janpio janpio assigned divyenduz and unassigned tomhoule and pantharshit00 Oct 23, 2019
@janpio janpio modified the milestones: Preview 15, Preview 16 Oct 28, 2019
@pantharshit00 pantharshit00 added bug/0-needs-info More information is needed for reproduction. and removed bug/1-repro-available A reproduction exists and needs to be confirmed. labels Oct 29, 2019
@pantharshit00
Copy link
Contributor

I am also unable to reproduce this.

@divyenduz
Copy link
Author

Closing this one then, I will raise it again if I am able to repro this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/0-needs-info More information is needed for reproduction. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

4 participants