GithubHelp home page GithubHelp logo

medz / prisma-dart Goto Github PK

View Code? Open in Web Editor NEW
422.0 11.0 23.0 38.97 MB

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.

Home Page: https://prisma.pub

License: BSD 3-Clause "New" or "Revised" License

Dart 98.72% Dockerfile 0.71% Shell 0.57%
orm prisma dart flutter mysql cockroachdb mariadb mongodb postgresql sqlite

prisma-dart's Introduction

Hi there 👋

Keep calm and coding.

I'm Seven Du, a full-stack developer starting a business. Founded Odroe Inc, a company dedicated to open source software.

Motto: if(true == false) false = true

🇨🇳 Chengdu・👨🏻‍💻 Full-stack Developer

E-Mail: shiweidu at outlook dot com

Language:Dart❤️、Rust🤩、TypeScript/JavaScript(ES6+)🥳、Swift

Framework:Flutter、Vue.js、React.js、Nest.js、And any more...

prisma-dart's People

Contributors

ali1ammar avatar aschulz90 avatar boltomli avatar dependabot[bot] avatar eseidel avatar github-actions[bot] avatar imgbotapp avatar jacobaraujo7 avatar leynier avatar linloir avatar medz avatar nikosportolos avatar petermx avatar rajput-hemant avatar skilllan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prisma-dart's Issues

Assert error in GraphQLArg class.

This assertion make no sense to me.
image

If not required, the assert will raise an error.

SUGGESTION: isRequired ? value != null : true

Error in 2.2.1

After dart run orm generate

PS D:\Projects\FTeamERP\backend> dart run orm generate
Generate client...                      Could not format because the source could not be parsed:

line 6826, column 43 of .: Unterminated string literal.
     ╷
6826 │ const  String  schema = 'generator client {
     │                                           ^
     ╵
line 6903, column 5 of .: Unterminated string literal.
     ╷
6903 │ \n}';
     │     ^
     ╵
line 6826, column 25 of .: Expected to find ';'.
     ╷
6826 │ const  String  schema = 'generator client {
     │                         ^^^^^^^^^^^^^^^^^^^
     ╵
line 6827, column 1 of .: Expected a method, getter, setter or operator declaration.
     ╷
6827 │ \n  provider = "prisma-client-dart"
     │ ^
     ╵
line 6827, column 16 of .: Expected to find ';'.
     ╷
6827 │ \n  provider = "prisma-client-dart"
     │                ^^^^^^^^^^^^^^^^^^^^
     ╵
line 6828, column 1 of .: Expected a method, getter, setter or operator declaration.
     ╷
6828 │ \n  previewFeatures = ["interactiveTransactions"]
     │ ^
     ╵
line 6828, column 49 of .: Expected to find ';'.
     ╷
6829 │ \n}
     │  ^
     ╵
(276 more errors...)
#0      DartFormatter.formatSource (package:dart_style/src/dart_formatter.dart:144:7)
#1      DartFormatter.format (package:dart_style/src/dart_formatter.dart:72:12)
#2      generator (file:///C:/Users/jacob/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/orm-2.2.1/bin/src/generator/generator.dart:102:38)
#3      GenerateCommand.runGenerator (file:///C:/Users/jacob/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/orm-2.2.1/bin/src/commands/generate_command.dart:150:11)
<asynchronous suspension>
#4      GenerateCommand.run (file:///C:/Users/jacob/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/orm-2.2.1/bin/src/commands/generate_command.dart:111:30)
<asynchronous suspension>
#5      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#6      main (file:///C:/Users/jacob/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/orm-2.2.1/bin/orm.dart:50:5)
<asynchronous suspension>

Failed to start the query engine: Connection refused

PrismaClientInitializationError:
  message: Failed to start the query engine: Connection refused
  errorCode: null
  clientVersion: 2.4.5
#0      BinaryEngine._createProcess (package:orm/src/engine_core/binary/binary_engine_io.dart:441:7)
<asynchronous suspension>
#1      BinaryEngine.start (package:orm/src/engine_core/binary/binary_engine_io.dart:333:17)
<asynchronous suspension>
#2      BinaryEngine.request (package:orm/src/engine_core/binary/binary_engine_io.dart:290:5)
<asynchronous suspension>
#3      ModelDelegate.findMany (package:package_name/prisma_client.dart:55755:42)
<asynchronous suspension>
...

The database is PlanetScale, so I don't have any Docker compose file to set up with SSL or other...
Running the Dart Server locally I have no problems, but in staging/production gives me that error (the connection strings are the same).

@medz Anything to suggest?

Originally posted by @AndryHTC in #55 (comment)

Nullable fields generating broken field implementations

While running the User / Post example in the README, I've encountered a problem with the initial generated code.

It seems that nullable fields (e.g., name String?) generate the following Dart code:

final _i2.PrismaNullable<_i2.PrismaUnion<StringNullableWithAggregatesFilter, String, _i2.PrismaNull>> name;

Which breaks, because the class definition for PrismaUnion accepts 2 type parameters

class PrismaUnion<T0, T1> {}

Yet we've provided three

PrismaUnion<StringNullableWithAggregatesFilter, String, _i2.PrismaNull>

Could not find a file named "pubspec.yaml"

After adding orm to my flutter project I tried the following in the terminal.

"dart run orm init --datasource-provider sqlite"

But I got the following error:

Could not find a file named "pubspec.yaml" in "C:\Users\Anton\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\app_links-3.3.0".
#0 new Pubspec.load (package:pub/src/pubspec.dart:306:7)
#1 new Package.load (package:pub/src/package.dart:128:29)
#2 SystemCache.load (package:pub/src/system_cache.dart:105:20)
#4 Entrypoint.packageGraph (package:pub/src/entrypoint.dart:116:54)
#5 getExecutableForCommand (package:pub/src/executable.dart:339:19)
#6 RunCommand.run (package:dartdev/src/commands/run.dart:250:32)
#7 CommandRunner.runCommand (package:args/command_runner.dart:209:27)
#8 DartdevRunner.runCommand (package:dartdev/dartdev.dart:231:30)
#9 CommandRunner.run. (package:args/command_runner.dart:119:25)
#10 new Future.sync (dart:async/future.dart:302:31)
#11 CommandRunner.run (package:args/command_runner.dart:119:14)
#12 runDartdev (package:dartdev/dartdev.dart:66:29)
#13 main (file:///C:/b/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:11:9)
#14 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:293:32)
#15 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

Am I missing something?

Error: The method 'fromJson' isn't defined for the class 'Type'

  • prisma_client.dart

image
image

Flutter 3.3.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ffccd96b62 (10 weeks ago) • 2022-08-29 17:28:57 -0700
Engine • revision 5e9e0e0aa8
Tools • Dart 2.18.0 • DevTools 2.15.0

mongodb

orm: ^2.4.3

Prisma engines

@Ali1Ammar I have done Prisma binary engines download functionality and db push/format. Currently my job is to develop a binary client proxy for query engine, but given that you have already completed https://github.com/Ali1Ammar/prisma-client-dart that is query engine proxy and client generation. I had to reassign work.

Since you've already written the query engine, I think you can just migrate the code over and it will work.

Next, I will use Rust to write Prisma query engine's C APIs dylib to make Prisma for Dart support Flutter.

Regarding the Prisma Data Proxy part, I think we can revisit the distribution of development work after the dylib development is complete.

@medz TODO:

  • A dylib for Prisma query engine written in Rust

@Ali1Ammar TODO:

  • Complete the binary part of Prisma query engine.

Problems using Model with relation

schema.prisma example

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

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

enum Role {
  dev
  manager
  admin
}

model Client {
  id                  Int               @id @default(autoincrement())
  createdAt           DateTime          @default(now())
  name                String          
  cnpj                String               
  address             String          
  city                String          
  state               String          
  country             String          
  imageUrl            String?         
  active              Boolean           @default(true)
  projects            Project[]        
}

model User {
  id                  Int               @id @default(autoincrement())
  createdAt           DateTime          @default(now())
  email               String            @unique
  name                String    
  imageUrl            String?   
  active              Boolean           @default(true)
  password            String    
  role                Role              @default(dev)
  project             UserOnProject[]       
}

model Project {
  id                  Int               @id @default(autoincrement())
  createdAt           DateTime          @default(now())
  title               String          
  description         String            @default("")
  imageUrl            String?         
  active              Boolean           @default(true)
  user                UserOnProject[]   
  clientId            Int
  client              Client             @relation(fields: [clientId], references: [id])
}



model UserOnProject {
  user                User              @relation(fields: [idUser], references: [id])
  idUser              Int
  project             Project           @relation(fields: [idProject], references: [id])
  idProject           Int

  @@id([idUser, idProject])
}

The code generator fails to generate and so the json_serializable fails.

image

Charset UT8

Apparently, at some point the charset conversions are not happening as they should. Example of accented words:

image

(Two last propertie).

I am using SQLite provider.
image
SQLite DIrectly is all right.

Feature: add support for migration?

How does this library help me with migration of databases that are already deployed on customer's machines, I need to rev the schema, let's say for example, change a column name, or add a new column, or change the column type. Does this library help create the "migration" code needed to apply changes on the deployed on customer's machine's at runtime once customer has upgrated the version of the app?

Could not find query engine binary for current platform "linux" in query-engine path.

The problem happens when I try to dockerize the app. I use prisma with dart_frog and postgres
Here's what happens when I try calling an endpoint that does some db query with prisma.

build-server-1  | [ERROR] 2022-10-26 19:17:17.623771    0:00:00.001226  POST    /auth/user
build-server-1  | PrismaClientInitializationError:
build-server-1  |   message: Could not find query engine binary for current platform "linux" in query-engine path.
build-server-1  |
build-server-1  | This probably happens, because you built Prisma Client on a different platform.
build-server-1  |
build-server-1  | Searched Locations:
build-server-1  |   - /
build-server-1  |   - /app/bin
build-server-1  |   - /app/.dart_tool/prisma
build-server-1  |
build-server-1  | You already added the platform "linux" to the "generator" block in the "schema.prisma" file as described in https://pris.ly/d/client-generator, but something went wrong. That's suboptimal.
build-server-1  |
build-server-1  | Please create an issue at https://github.com/odroe/prisma-dart/issues/new
build-server-1  |   errorCode: null
build-server-1  |   clientVersion: 2.4.0
build-server-1  |
build-server-1  | package:shelf/src/middleware/logger.dart 30  logRequests.<fn>.<fn>.<fn>
build-server-1  |
build-server-1  | ERROR - 2022-10-26 19:17:17.626072
build-server-1  | POST /auth/user
build-server-1  | Error thrown by handler.
build-server-1  | PrismaClientInitializationError:
build-server-1  |   message: Could not find query engine binary for current platform "linux" in query-engine path.
build-server-1  |
build-server-1  | This probably happens, because you built Prisma Client on a different platform.
build-server-1  |
build-server-1  | Searched Locations:
build-server-1  |   - /
build-server-1  |   - /app/bin
build-server-1  |   - /app/.dart_tool/prisma
build-server-1  |
build-server-1  | You already added the platform "linux" to the "generator" block in the "schema.prisma" file as described in https://pris.ly/d/client-generator, but something went wrong. That's suboptimal.
build-server-1  |
build-server-1  | Please create an issue at https://github.com/odroe/prisma-dart/issues/new
build-server-1  |   errorCode: null
build-server-1  |   clientVersion: 2.4.0
build-server-1  |

Here's my scheme.prisma file:

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider        = "prisma-client-dart"
  previewFeatures = ["interactiveTransactions"]
  output          = "../lib/prisma_client.dart"
  binaryTargets   = ["native", "linux-musl"]
}

datasource db {
  provider = "postgresql"
  url      = "postgres://app_user:password@localhost:5432/app_db?schema=public"
}

model User {
  id            Int           @id @default(autoincrement())
  email         String
  passwordHash  String
  firstName     String
  lastName      String
  createdAt     DateTime      @default(now())
  updatedAt     DateTime      @updatedAt
  restaurants   Restaurant[]
  sessions      UserSession[]
}

model UserSession {
  id            Int           @id @default(autoincrement())
  userId        Int
  accessToken   String
  refreshToken  String
  expiresAt     DateTime
  createdAt     DateTime      @default(now())
  updatedAt     DateTime      @updatedAt
  
  user          User          @relation(fields: [userId], references: [id])
}

model Restaurant {
  id            Int           @id @default(autoincrement())
  userId        Int
  address       String
  meals         Meal[]
  createdAt     DateTime      @default(now())
  updatedAt     DateTime      @updatedAt

  user          User          @relation(fields: [userId], references: [id])
}


model Meal {
  id            Int           @id @default(autoincrement())
  restaurantId  Int
  name          String
  createdAt     DateTime      @default(now())
  updatedAt     DateTime      @updatedAt

  restaurant    Restaurant    @relation(fields: [restaurantId], references: [id])
}

Development environment not working

I'm trying to use the development DATABASE_URL that I put into the prisma/development.dart file, but when I run everything in debug mode, Prisma still uses the production DATABASE_URL in lib/src/prisma_configurator.dart.

What am I missing here?

Unit test

Unit testing is necessary to support long-term development.

Prisma ORM for Dart 3.0

Due to the limitation of the Dart language, many functions of Prisma ORM for Dart cannot be realized, the most common ones are select, include.

There are many other problems:

  1. Codegen is too complex
  2. Difficult to add new features

The guesses for the v3 version are as follows:

  1. Give up type safety and use Map
  2. Give up building a private client and use Prisma DMMF to build a general client
  3. Abandon the binary engine (although it supports conventional platforms and architectures, but it is troublesome for serverless or Docker), and build a brand new engine suitable for Dart.
  4. For parameter input, use chain reaction to build

Could not find query engine binary for current platform "android"

I've been trying to the Prisma to work with flutter for the android platform but have been getting this error lately.

E/flutter ( 9332): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PrismaClientInitializationError:
E/flutter ( 9332):   message: Could not find query engine binary for current platform "android" in query-engine path.
E/flutter ( 9332):
E/flutter ( 9332): This probably happens, because you built Prisma Client on a different platform.
E/flutter ( 9332):
E/flutter ( 9332): Searched Locations:
E/flutter ( 9332):   - /
E/flutter ( 9332):   - /Users/luca/Work/vertigo-app/.dart_tool/prisma
E/flutter ( 9332):
E/flutter ( 9332): You already added the platform "android" to the "generator" block in the "schema.prisma" file as described in https://pris.ly/d/client-generator, but something went wrong. That's suboptimal.
E/flutter ( 9332):
E/flutter ( 9332): Please create an issue at https://github.com/odroe/prisma-dart/issues/new
E/flutter ( 9332):   errorCode: null
E/flutter ( 9332):   clientVersion: 2.4.3
E/flutter ( 9332):
E/flutter ( 9332): #0      BinaryEngine.executable (package:orm/src/engine_core/binary/binary_engine_io.dart:198:5)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #1      BinaryEngine._createProcess (package:orm/src/engine_core/binary/binary_engine_io.dart:355:7)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #2      BinaryEngine.start (package:orm/src/engine_core/binary/binary_engine_io.dart:333:17)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #3      BinaryEngine.request (package:orm/src/engine_core/binary/binary_engine_io.dart:290:5)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #4      UserDelegate.findMany (package:eye/prisma_client.dart:46227:42)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #5      DBManager.getUserIDs (package:eye/database/db_manager.dart:833:19)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #6      DBManager.loginFirstUser (package:eye/database/db_manager.dart:1104:19)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332):
D/SurfaceComposerClient( 9332): VRR [FRTC] client handle [bufferId:18446744073709551615 framenumber:0] [ffffffff, ffffffff]
The Flutter DevTools debugger and profiler on LE2123 is available at:
http://127.0.0.1:9100?uri=http://127.0.0.1:64567/4YgkH5OkBAY=/
E/flutter ( 9332): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PrismaClientInitializationError:
E/flutter ( 9332):   message: Could not find query engine binary for current platform "android" in query-engine path.
E/flutter ( 9332):
E/flutter ( 9332): This probably happens, because you built Prisma Client on a different platform.
E/flutter ( 9332):
E/flutter ( 9332): Searched Locations:
E/flutter ( 9332):   - /
E/flutter ( 9332):   - /Users/luca/Work/vertigo-app/.dart_tool/prisma
E/flutter ( 9332):
E/flutter ( 9332): You already added the platform "android" to the "generator" block in the "schema.prisma" file as described in https://pris.ly/d/client-generator, but something went wrong. That's suboptimal.
E/flutter ( 9332):
E/flutter ( 9332): Please create an issue at https://github.com/odroe/prisma-dart/issues/new
E/flutter ( 9332):   errorCode: null
E/flutter ( 9332):   clientVersion: 2.4.3
E/flutter ( 9332):
E/flutter ( 9332): #0      BinaryEngine.executable (package:orm/src/engine_core/binary/binary_engine_io.dart:198:5)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #1      BinaryEngine._createProcess (package:orm/src/engine_core/binary/binary_engine_io.dart:355:7)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #2      BinaryEngine.start (package:orm/src/engine_core/binary/binary_engine_io.dart:333:17)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #3      BinaryEngine.request (package:orm/src/engine_core/binary/binary_engine_io.dart:290:5)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332): #4      DiaryEntryDelegate.findMany (package:eye/prisma_client.dart:51066:42)
E/flutter ( 9332): <asynchronous suspension>
E/flutter ( 9332):
E/flutter ( 9332): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PrismaClientInitializationErro

The head of my Prisma schema looks as following:

generator client {
  provider        = "prisma-client-dart"
  previewFeatures = ["interactiveTransactions"]
  binaryTargets   = ["linux-arm64-openssl-3.0.x"]
}

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

Error running generate

Hi, I was just trying out this library but having trouble running dart run orm generate.
It results in the following error

Download binray query engine           23.7s
FormatException: Unexpected character (at character 1)
/home/ankur/Projects/Dart/tasks/.dart_tool/prisma/query-engine: error while...
^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1383:5)
#1      _ChunkedJsonParser.parseNumber (dart:convert-patch/convert_patch.dart:1250:9)
#2      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:915:22)
#3      _parseJson (dart:convert-patch/convert_patch.dart:35:10)
#4      JsonDecoder.convert (dart:convert/json.dart:612:36)
#5      JsonCodec.decode (dart:convert/json.dart:216:41)
#6      jsonDecode (dart:convert/json.dart:155:10)
#7      GenerateCommand.run (file:///home/ankur/.pub-cache/hosted/pub.dartlang.org/orm-2.2.2/bin/src/commands/generate_command.dart:62:20)
<asynchronous suspension>
#8      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#9      main (file:///home/ankur/.pub-cache/hosted/pub.dartlang.org/orm-2.2.2/bin/orm.dart:50:5)
<asynchronous suspension>

I'm using ubuntu 22.04, schema file is

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

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

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

model Task {
  id   String   @id @default(cuid())
  task String
  done Boolean  @default(false)
  due  DateTime @default(dbgenerated("(datetime('now', '+2 days'))")) //sqlite
}

Sync version to prisma

The version number of the Node prisma package has been released to 4.3 or newer(https://www.npmjs.com/package/prisma).

Plan to synchronize version numbers after all features are developed. Synchronizing version numbers has the following benefits:

  1. Synchronize the commit hash of the binary engine to confirm that the commit engine is the latest and most stable.
  2. The version of the dynamic library is synchronized. If the binary is the same, the C API of the dynamic library can complete the synchronization.
  3. Function identification, Prisma TS client is a template of the orm package, which makes Prisma official stabilization more useful for this package.
  4. Automatic requirement submission, using CI to monitor the release of Prisma node package, and then automatically submitting Issue has helped us to synchronize functions.

Create throws assertion error

Following the creation example, I run into this problem:

image

Apparently the 'data' property is waiting for a PrismaUnion<ClientCreateInput, ClientUncheckedCreateInput>.
I tried to use PrismaUnion.zero, but I end up falling for this assertion.

image

This assert make no sense to me, because if use the factory zero or one throws a assertion error.
image

SUGGESTION: zero != null || one != null

Could not generate

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

QueryRaw unavailable

Hello, I need to use queryRaw, but it not see in options available in instance prisma.
I think it's essential if some of the orm's features for handling data aren't working properly at this stage of the library.
Screenshot 2022-11-19 at 16 04 15

When there is an error in the generate command. Print the prisma error message to the console.

At the moment, if the schema triggers an error from Prisma. The error will be something like this:

FormatException: Unexpected end of input (at character 1)

This happens because the generate command doesn't consider the stderr's value before trying to parse the document from the JSON response.

The solution could be that before the generator command tries to parse the JSON response, it could check the stderr's value and in case it's not empty. It could print the actual error message from Prisma.

Unhandled exception: type 'Null' is not a subtype of type 'String' in type cast

I've been trying to get the orm to work. I am able to create the initial config files via "flutter pub run orm init" but when I try to use db push with the example models from the Website I get the following Errors.

image

Is this a common Issue or does it have to do with my System?

Im working on an M1 Mac. Just if that's a necessary info.

Connecting to Atlas MongoDB

I have been struggling for 3 days to connect to either local or Atlas Mongo. I continue to receive a Connection Refused with no error code. I have tried every variation of the connection string including adding authSource=admin. The connection string works fine in mongosh and Compass.

Here is my current connection string:
mongodb+srv://xxxxxx:[email protected]/cbm?retryWrites=true&w=majority&ssl=true&authSource=admin

This is the error I get back:
PrismaClientInitializationError:
message: Failed to start the query engine: Connection refused
errorCode: null
clientVersion: 2.4.3

feature - Customize the configuration file location and use a simpler configuration format (not YAML)

Add a runtime configuration file, which is added to git ignore, and moves to other directories with the program's compiled binaries.

E.g: .prismarc:

DATABASE_URL = postgres://seven@localhost:5432/demo?schema=public

Add configuration items in pubspec.yaml to specify the path of the runtime configuration file (compared to the location of pubspec.yaml):

prisma:
  prismarc: .prismarc # Prisma runtime configuration, and dotenv can be selected or set together
  dotenv: .env # Prisma runtime load dotenv file, and prismarc can be selected or set together
  schame: prisma/schema.prisma # Custom Prisma schema file path

Find runtime configuration order:

  • step 1: Read the prisma runtime configuration file path in pubspec.yaml, if it is not configured or can't find pubspec.yaml, it will pop up. Note: It is relatively easy to find the pubspec.yaml file, just read it directly from the current running directory.
  • step 2: Read the .prismarc configuration file from the current working directory, and exit if the file does not exist
  • step 3: Read a .prismarc file from the current script directory
  • step 4: Merge environment variables

Generated freezed file has undefined class error

When I run the dart run build_runner build command, the generated file has errors which is Undefined class '$PrismaNullCopyWith'. This happens when you have prisma scheme nullable field (everything works out when you don't have nullable field).

The dependencies that I have is:

dependencies:
  orm: ^2.6.0
dev_dependencies:
  build_runner: ^2.3.3
  freezed: ^2.3.2
  json_serializable: ^6.5.4

The scheme that I have is:

generator client {
  provider = "prisma-client-dart"
}

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

model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String
  post      Post?    @relation(fields: [postId], references: [id])
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  postId    Int
}

model Post {
  id        Int      @id @default(autoincrement())
  name      String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  User      User[]
}

Here is the screenshot of the errors:
image

My prisma dart not work

my code here : https://github.com/bobwatcherx/fixprismadart.git

i follow you web tutorial , but not work with me : https://prisma.pub/getting-started

MY DART VERSION : 📎
Dart SDK version: 2.18.2 (stable) (Tue Sep 27 13:24:11 2022 +0200) on "linux_x64"

see log error message :

root@ubuntux-Lenovo-V145-14AST:/home/ubuntux/belajar/dartapp/mainapp# dart run bin/mainapp.dart 
   Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.
  /
📎
lib/prisma_client.dart:14:6: Error: Error when reading 'lib/prisma_client.g.dart': No such file or directory
part 'prisma_client.g.dart';
     ^
lib/prisma_client.dart:14:6: Error: Can't use 'lib/prisma_client.g.dart' as a part, because it has no 'part of' declaration.
part 'prisma_client.g.dart';
     ^
bin/mainapp.dart:15:19: Error: The argument type 'String' can't be assigned to the parameter type 'PrismaUnion<String, PrismaNull>?'.
 - 'PrismaUnion' is from 'package:orm/src/runtime/prisma_union.dart' ('/root/.pub-cache/hosted/pub.dartlang.org/orm-2.4.0/lib/src/runtime/prisma_union.dart').
 - 'PrismaNull' is from 'package:orm/src/runtime/prisma_null.dart' ('/root/.pub-cache/hosted/pub.dartlang.org/orm-2.4.0/lib/src/runtime/prisma_null.dart').
            name: "Seven",
                  ^
lib/prisma_client.dart:2536:7: Error: Method not found: '_$AggregateUserFromJson'.
      _$AggregateUserFromJson(json);
      ^^^^^^^^^^^^^^^^^^^^^^^
lib/prisma_client.dart:2554:36: Error: The method '_$AggregateUserToJson' isn't defined for the class 'AggregateUser'.
 - 'AggregateUser' is from 'package:mainapp/prisma_client.dart' ('lib/prisma_client.dart').
Try correcting the name to the name of an existing method, or defining a method named '_$AggregateUserToJson'.
  Map<String, dynamic> toJson() => _$AggregateUserToJson(this);
                                   ^^^^^^^^^^^^^^^^^^^^^
lib/prisma_client.dart:2575:7: Error: Method not found: '_$UserGroupByOutputTypeFromJson'.
      _$UserGroupByOutputTypeFromJson(json);
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/prisma_client.dart:2599:36: Error: The method '_$UserGroupByOutputTypeToJson' isn't defined for the class 'UserGroupByOutputType'.
 - 'UserGroupByOutputType' is from 'package:mainapp/prisma_client.dart' ('lib/prisma_client.dart').
Try correcting the name to the name of an existing method, or defining a method named '_$UserGroupByOutputTypeToJson'.
  Map<String, dynamic> toJson() => _$UserGroupByOutputTypeToJson(this);
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/prisma_client.dart:2617:7: Error: Method not found: '_$AggregatePostFromJson'.
      _$AggregatePostFromJson(json);
      ^^^^^^^^^^^^^^^^^^^^^^^
lib/prisma_client.dart:2635:36: Error: The method '_$AggregatePostToJson' isn't defined for the class 'AggregatePost'.
 - 'AggregatePost' is from 'package:mainapp/prisma_client.dart' ('lib/prisma_client.dart').
Try correcting the name to the name of an existing method, or defining a method named '_$AggregatePostToJson'.
  Map<String, dynamic> toJson() => _$AggregatePostToJson(this);
                                   ^^^^^^^^^^^^^^^^^^^^^
lib/prisma_client.dart:2658:7: Error: Method not found: '_$PostGroupByOutputTypeFromJson'.
      _$PostGroupByOutputTypeFromJson(json);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.