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

only one @updatedAt is filled by the QE although multiple are accepted in the schema #15176

Closed
do4gr opened this issue Sep 4, 2022 · 0 comments · Fixed by prisma/prisma-engines#3168 or #15415
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. team/schema Issue for team Schema. topic: updatedAt
Milestone

Comments

@do4gr
Copy link
Member

do4gr commented Sep 4, 2022

We should either allow and document only one use of @updatedAt per model or update all of them if the row is touched instead of only the first one.

// Valid datamodel
model TestModel {
      id                    Int       @id
      test                  Int?
      updatedAt_w_default   DateTime  @default(now()) @updatedAt
      updatedAt_wo_default  DateTime? @updatedAt
      createdAt             DateTime  @default(now())
}
field.rs
// code only surfacing first updatedAt per model
 pub fn updated_at(&self) -> &Option<ScalarFieldRef> {
        self.updated_at.get_or_init(|| {
            self.scalar_weak()
                .iter()
                .map(|sf| sf.upgrade().unwrap())
                .find(|sf| sf.is_updated_at)
        })
    }

@do4gr do4gr added kind/bug A reported bug. team/client Issue for team Client. team/schema Issue for team Schema. bug/2-confirmed Bug has been reproduced and confirmed. topic: updatedAt labels Sep 4, 2022
@janpio janpio added this to the 4.4.0 milestone Sep 9, 2022
@danstarns danstarns self-assigned this Sep 20, 2022
danstarns added a commit that referenced this issue Sep 20, 2022
millsp added a commit that referenced this issue Sep 26, 2022
Co-authored-by: pierre <pierreantoine.urvoy@gmail.com>
Co-authored-by: Matthias Oertel <Matthias.oertel@gmx.net>
Co-authored-by: Pierre-Antoine Mills <pierreantoine.urvoy@gmail.com>
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/client Issue for team Client. team/schema Issue for team Schema. topic: updatedAt
Projects
None yet
3 participants