From 2afc7ad2a4ea34b42f73062f3d6a29c697761e54 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Tue, 19 Mar 2024 00:29:50 +0800 Subject: [PATCH 1/4] chore(WIP): test --- .gitignore | 1 + prisma/schema.prisma | 54 ++++++++++++-------------------------------- 2 files changed, 15 insertions(+), 40 deletions(-) diff --git a/.gitignore b/.gitignore index 774f6ad9..ca706033 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Files and directories created by pub. .dart_tool/ .packages +.env node_modules/ # Omit committing pubspec.lock for library packages; see diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ca95470f..b3f93ea5 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,46 +1,20 @@ -// This is your Prisma schema file, -// learn more about it in the docs: https://pris.ly/d/prisma-schema - -generator dart_client { - provider = "dart run orm" - output = "dart" -} - -generator js_client { - provider = "prisma-client-js" -} - -generator dmmf { - provider = "dart run tool/dmmf_generator.dart" +generator client { + provider = "dart run orm" + output = "../lib/src/prisma_client/" + previewFeatures = ["fullTextSearch", "fullTextIndex"] } datasource db { - provider = "mysql" - url = "mysql://seven@localhost:5432/prisma-dart" -} - -enum Role { - user - owner -} - -model User { - id Int @id @default(autoincrement()) - name String - role Role @default(user) - price Decimal - size BigInt - bytes Bytes - json Json? - age Int? - count Float - createdAt DateTime @default(now()) - posts Post[] + provider = "mysql" + url = env("DATABASE_URL") + relationMode = "prisma" } -model Post { - id String @id @default(cuid()) - title String - author User @relation(fields: [userId], references: [id]) - userId Int +model Soggetto { + uuid String @id @default(uuid()) + ragioneSociale String + iban String? + negozioPreferitoUuid String? + codiceFiscale String? @unique + note String? } From 5d0bd957d28e20a60b02a34511f50fc43a94f0a7 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Tue, 26 Mar 2024 02:33:23 +0800 Subject: [PATCH 2/4] RE #344 --- bin/orm.dart | 7 +++++-- pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/orm.dart b/bin/orm.dart index 6072c39d..af1f4eab 100644 --- a/bin/orm.dart +++ b/bin/orm.dart @@ -40,11 +40,14 @@ Future generate(GeneratorOptions options) async { orderDirectives: true, ); final source = library.accept(emitter); - final formated = formatter.format(source.toString()); + // final formated = formatter.format(source.toString()); final output = await File(join(options.generator.output!.value, filename)) .autoCreate(); - await output.writeAsString(formated); + // TODO: Bug in dart formatter, https://github.com/medz/prisma-dart/issues/344#issuecomment-2018074768 + await output.writeAsString(source.toString()); + + // await output.writeAsString(formated); } // Copy prisma query engine. diff --git a/pubspec.yaml b/pubspec.yaml index e4550461..5dfb06e2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: orm description: Next-generation ORM for Dart & Flutter | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB. -version: 4.0.1 +version: 4.0.1-issue.344 homepage: https://prisma.pub repository: https://github.com/medz/prisma-dart funding: From a64fb29888227071d39150d615f423236ebe8b2e Mon Sep 17 00:00:00 2001 From: Seven Du Date: Thu, 28 Mar 2024 13:54:15 +0800 Subject: [PATCH 3/4] fix(generator): fix for `code_builder` not handling CRLF case. Temporary fix to uniformly convert CRLF to LF --- bin/orm.dart | 7 ++----- bin/src/generate_client.dart | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/orm.dart b/bin/orm.dart index af1f4eab..6072c39d 100644 --- a/bin/orm.dart +++ b/bin/orm.dart @@ -40,14 +40,11 @@ Future generate(GeneratorOptions options) async { orderDirectives: true, ); final source = library.accept(emitter); - // final formated = formatter.format(source.toString()); + final formated = formatter.format(source.toString()); final output = await File(join(options.generator.output!.value, filename)) .autoCreate(); - // TODO: Bug in dart formatter, https://github.com/medz/prisma-dart/issues/344#issuecomment-2018074768 - await output.writeAsString(source.toString()); - - // await output.writeAsString(formated); + await output.writeAsString(formated); } // Copy prisma query engine. diff --git a/bin/src/generate_client.dart b/bin/src/generate_client.dart index 62df9a99..e68207a9 100644 --- a/bin/src/generate_client.dart +++ b/bin/src/generate_client.dart @@ -85,7 +85,9 @@ extension on Generator { .assign( refer('BinaryEngine', 'package:orm/engines/binary.dart') .newInstance([], { - 'schema': literalString(options.schema), + 'schema': + // TODO: https://github.com/dart-lang/code_builder/issues/452 + literalString(options.schema.replaceAll('\r\n', '\n')), 'datasources': refer('datasources'), }), ) From 84b412006bbdc06fc7c4214b2ba1f706df90e38d Mon Sep 17 00:00:00 2001 From: Seven Du Date: Thu, 28 Mar 2024 13:57:34 +0800 Subject: [PATCH 4/4] chore(version): 4.0.3 --- CHANGELOG.md | 19 +++++++++++++++++++ docs/getting-started/index.md | 4 ++-- lib/version.dart | 2 +- pubspec.yaml | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f719a8d..565db2e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +# Prisma Client Dart v4.0.3 + +To install Prisma Client for Dart v4.0.3 run: + +```bash +dart pub add orm:4.0.3 +``` + +Or update your `pubspec.yaml` file: + +```yaml +dependencies: + orm: 4.0.3 +``` + +## What's Changed + +- **Bug**: fix for `code_builder` not handling CRLF case + # Prisma Client Dart v4.0.2 To install Prisma Client for Dart v4.0.2 run: diff --git a/docs/getting-started/index.md b/docs/getting-started/index.md index 5acb2f35..5de00ad8 100644 --- a/docs/getting-started/index.md +++ b/docs/getting-started/index.md @@ -77,12 +77,12 @@ bun add prisma Please run the following command to install `orm`: ```bash -dart pub add orm:4.0.2 +dart pub add orm:4.0.3 ``` Or add the following to your `pubspec.yaml` file: ```yaml dependencies: - orm: ^4.0.2 // [!code focus] + orm: ^4.0.3 // [!code focus] ``` diff --git a/lib/version.dart b/lib/version.dart index 5cf42ff7..52dbd5ba 100644 --- a/lib/version.dart +++ b/lib/version.dart @@ -1,3 +1,3 @@ library prisma.version; -const version = '4.0.2'; +const version = '4.0.3'; diff --git a/pubspec.yaml b/pubspec.yaml index 83f3597b..e3e90bdd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: orm description: Next-generation ORM for Dart & Flutter | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB. -version: 4.0.2 +version: 4.0.3 homepage: https://prisma.pub repository: https://github.com/medz/prisma-dart funding: