medz / prisma-dart

Prisma Client Dart is an auto-generated type-safe ORM. It uses Prisma Engine as the data access layer and is as consistent as possible with the Prisma Client JS/TS APIs.
https://prisma.pub
BSD 3-Clause "New" or "Revised" License
450 stars 30 forks source link

Wrong generate model, why? #355

Closed PrzemyslawPluszowy closed 5 months ago

PrzemyslawPluszowy commented 5 months ago

"@prisma/engines": "4.16.2"

  provider = "dart run orm"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

model User {
  id    Int     @id @default(autoincrement())
  email String
  name  String?
}

pubspec:

description: An new Dart Frog application
version: 1.0.0+1
publish_to: none

environment:
  sdk: ">=3.0.0 <4.0.0"

dependencies:
  dart_frog: ^1.1.0
  json_annotation: ^4.8.1
  orm: ^4.1.0

dev_dependencies:
  build_runner: ^2.4.9
  json_serializable: ^6.7.1
  mocktail: ^1.0.0
  test: ^1.19.2
  very_good_analysis: ^5.1.0```

generated model
```class User {
  const User({
    this.id,
    this.email,
    this.name,
  });

  factory User.fromJson(Map json) => User(
        id: json['id'],
        email: json['email'],
        name: json['name'],
      );

  final int? id;

  final String? email;

  final String? name;

  Map<String, dynamic> toJson() => {
        'id': id,
        'email': email,
        'name': name,
      };
}

`

i have many error in generated file like "The argument type 'dynamic' can't be assigned to the parameter type 'String?'."

medz commented 5 months ago

Please set the very_good_analysis rule to exclude clients generated by Prisma. very_good_analysis because the client only satisfies the recommended rules for lints. Lints that use other rules need to be excluded by yourself

PrzemyslawPluszowy commented 5 months ago

thanks