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
436 stars 29 forks source link

If the type in .prisma is primitive list type like Int[], then the generated fromJson will cause error: #331

Closed medz closed 4 months ago

medz commented 4 months ago
          If the type in .prisma is primitive list type like Int[], then the generated fromJson will cause error:

type 'MappedListIterable<dynamic, dynamic>' is not a subtype of type 'Iterable<int>?'. It should change from like json['posts'] to List.from(json['posts']

model User {
    posts Int[]
}

Originally posted by @ebwood in https://github.com/medz/prisma-dart/issues/324#issuecomment-1930376433

ebwood commented 4 months ago

Thanks for your work @medz. By the way, is there a way to generate toJson in the generated model class? I want to send json data from model to client, so I have to manual add extension method to it, it's too verbose.

medz commented 4 months ago

Thanks for your work @medz. By the way, is there a way to generate toJson in the generated model class? I want to send json data from model to client, so I have to manual add extension method to it, it's too verbose.

Understand your problem, and I will create a new feature to implement it.