Skip to content

ZModel accepts @db.* native type attributes on the sqlite provider (Prisma rejects them) #2759

Description

@ymc9

Problem

ZModel's @db.* native type attributes are validated against the field's type (@@@targetField) but not against the datasource provider. Under a sqlite datasource, this compiles without any diagnostic:

datasource db {
    provider = "sqlite"
    url      = "file:./dev.db"
}

model M {
    id Int    @id
    v  String @db.VarChar(200) // silently ignored
}

Prisma's sqlite connector registers no native types at all and fails validation instead (verified with Prisma 6.19):

P1012: Native type VarChar is not supported for sqlite connector.

Since SQLite is affinity-typed, the migration engine (and DDL generation generally) ignores the attribute — so the user's declared intent is silently dropped. This surfaces when switching a project's provider to sqlite or when authoring against multiple providers: no error, no warning, no effect.

Expected

Validation should scope native type attributes by connector, like Prisma:

  • reject any @db.* attribute when the datasource provider is sqlite;
  • ideally, also enforce per-connector attribute lists for postgresql/mysql (e.g. @db.Uuid is pg-only, @db.LongText is mysql-only), which would additionally resolve the related @db.TinyInt-on-Boolean mismatch tracked separately.

Context

Found while building the Prisma physical-schema parity test suite for the native migration engine. Physical-schema parity itself is unaffected (Prisma-validated schemas can't contain the construct), but the validation behavior diverges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions