Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(fmt): quick-fixes break with no newline after model in schema #3444

Closed
Druue opened this issue Nov 25, 2022 · 0 comments · Fixed by #3447
Closed

bug(fmt): quick-fixes break with no newline after model in schema #3444

Druue opened this issue Nov 25, 2022 · 0 comments · Fixed by #3447
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: quick-fix
Milestone

Comments

@Druue
Copy link
Contributor

Druue commented Nov 25, 2022

Bug description

When a schema-file has no newline after the last model, lib::offset_to_position() panics. This also then results in no quick-fixes (populated from engines) being available as they all rely on this function.

running 1 test
thread 'code_actions::tests::relation_mode_prisma_missing_index' panicked at 'called `Option::unwrap()` on a `None` value', prisma-fmt/src/code_actions/relations.rs:336:79
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test code_actions::tests::relation_mode_prisma_missing_index ... FAILED

failures:

failures:
    code_actions::tests::relation_mode_prisma_missing_index

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 11 filtered out; finished in 0.01s

error: test failed, to rerun pass `-p prisma-fmt --test code_actions_tests`
Screen.Recording.2022-11-25.at.12.56.02.mov

Expected behavior

This should still just work

Prisma information

generator client {
    provider = "prisma-client-js"
    previewFeatures = ["referentialIntegrity"]
}

datasource db {
    provider = "mysql"
    url = env("TEST_DATABASE_URL")
    relationMode = "prisma"
}

model SomeUser {
    id Int @id
    posts Post[]
}

model Post {
    id Int @id
    userId Int
    user SomeUser @relation(fields: [userId], references: [id])
} // no newline
@Druue Druue added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. labels Nov 25, 2022
@Druue Druue self-assigned this Nov 25, 2022
@Jolg42 Jolg42 added this to the 4.7.0 milestone Nov 25, 2022
@Druue Druue changed the title bug(fmt): quick-fixes break with no newline after last model in schema bug(fmt): quick-fixes break with no newline after model in schema Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: quick-fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants