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

Could not generate #76

Closed
buraktabn opened this issue Dec 14, 2022 · 4 comments · Fixed by #77
Closed

Could not generate #76

buraktabn opened this issue Dec 14, 2022 · 4 comments · Fixed by #77

Comments

@buraktabn
Copy link

I have the following schema generated with dart run db pull.

generator client {
  provider        = "prisma-client-dart"
  previewFeatures = ["interactiveTransactions"]
}

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

model address {
  id                                                                       Int                      @id @default(autoincrement())
  street_number                                                            Int?
  route                                                                    Int?
  sub_locality                                                             Int?
  locality                                                                 Int?
  administrative_area_level_1                                              Int?
  administrative_area_level_2                                              Int?
  country                                                                  Int?
  postal_code                                                              Int?
  google_maps_place_id                                                     String                   @unique
  google_maps_url                                                          String?
  formatted_address                                                        String?
  vicinity                                                                 String?
  relation                                                                 String?
  name                                                                     String?
  address_component_address_routeToaddress_component                       address_component?       @relation("address_routeToaddress_component", fields: [route], references: [id], map: "fk_route")


  @@index([street_number, route, sub_locality, locality, administrative_area_level_1, administrative_area_level_2, country, postal_code, google_maps_place_id], map: "address_index")
}

model address_component {
  id                                                             Int       @id @default(autoincrement())
  long_name                                                      String
  short_name                                                     String
  types                                                          String[]
  address_address_routeToaddress_component                       address[] @relation("address_routeToaddress_component")

  @@unique([long_name, short_name, types])
}

When I run dart run orm generate, I get the following error. Not sure what's wrong.

/server % dart run orm --debug generate

Unhandled exception:
type 'Null' is not a subtype of type 'String' in type cast
#0      _$UniqueIndexFromJson (package:orm/src/dmmf/dmmf.g.dart:204:26)
#1      new UniqueIndex.fromJson (package:orm/src/dmmf/dmmf.dart:452:7)
#2      _$ModelFromJson.<anonymous closure> (package:orm/src/dmmf/dmmf.g.dart:117:35)
#3      MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#4      ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#5      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#6      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#7      new List.of (dart:core-patch/array_patch.dart:51:28)
#8      ListIterable.toList (dart:_internal/iterable.dart:213:44)
#9      _$ModelFromJson (package:orm/src/dmmf/dmmf.g.dart:118:12)
#10     new Model.fromJson (package:orm/src/dmmf/dmmf.dart:278:7)
#11     _$DatamodelFromJson.<anonymous closure> (package:orm/src/dmmf/dmmf.g.dart:88:29)
#12     MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#13     ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#14     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#15     new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#16     new List.of (dart:core-patch/array_patch.dart:51:28)
#17     ListIterable.toList (dart:_internal/iterable.dart:213:44)
#18     _$DatamodelFromJson (package:orm/src/dmmf/dmmf.g.dart:89:12)
#19     new Datamodel.fromJson (package:orm/src/dmmf/dmmf.dart:224:7)
#20     _$DocumentFromJson (package:orm/src/dmmf/dmmf.g.dart:10:28)
#21     new Document.fromJson (package:orm/src/dmmf/dmmf.dart:30:7)
#22     GenerateCommand.run (file:///home/burak/.pub-cache/hosted/pub.dartlang.org/orm-2.4.5/bin/src/commands/generate_command.dart:151:36)
<asynchronous suspension>
#23     CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#24     main (file:///home/burak/.pub-cache/hosted/pub.dartlang.org/orm-2.4.5/bin/orm.dart:69:5)
<asynchronous suspension>
% dart --version; uname -a 
Dart SDK version: 2.18.5 (stable) (Tue Nov 22 15:47:29 2022 +0000) on "linux_x64"
Linux workstation 5.19.0-26-generic #27-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 23 20:44:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
@medz
Copy link
Owner

medz commented Dec 14, 2022

@buraktabn Hey, Fix it in #71 , Update package to 2.4.5 version

@buraktabn
Copy link
Author

Already using 2.4.5 🤔

 dart run orm --version       
  Prisma CLI                              2.4.5
  Prisma Binary Engines                   694eea289a8462c80264df36757e4fdc129b1b32
  Prisma Query C API                      0.0.1
  Data Proxy Remote Client                4.6.1

@medz
Copy link
Owner

medz commented Dec 14, 2022

@buraktabn Emmmm, I need time to double check this question. I'll post a new fix when I'm done and let you know.

@medz medz linked a pull request Dec 14, 2022 that will close this issue
@medz medz closed this as completed in #77 Dec 14, 2022
@medz
Copy link
Owner

medz commented Dec 14, 2022

@buraktabn The bug was fixed in the just-released 2.4.6 version, and I also upgraded the Prisma engines version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants