Skip to content

Latest commit

 

History

History
834 lines (521 loc) · 29.9 KB

CHANGELOG.md

File metadata and controls

834 lines (521 loc) · 29.9 KB

Changelog

3.3.0 (2023-04-05)

Features

Bug Fixes

  • runtime: Fix repeat attach engine in finalizer (a5890b7)
  • runtime: Fix the engine stop caused by calling $disconnect outside of transaction (4448438)
  • runtime: Remove deprecated transactionId (2606456)

3.2.6 (2023-03-27)

Bug Fixes

  • engine: Fix ignored errors (fe8c89f)

3.2.5 (2023-03-27)

Bug Fixes

  • engine: Fix raw query always returning null, Thx @craiglabenz (efb15a6), closes #177
  • engine: Fix the order of throwing exceptions in transaction, Thx @PeterMX (f0b86bd), closes #181
  • engine: Prioritize checking for transaction errors, Thx @PeterMX (b3bedce)

3.2.4 (2023-03-26)

Bug Fixes

  • engine: maxWait and timeout were passed incorrectly (f4627b0), closes #178

3.2.3 (2023-03-21)

Bug Fixes

  • Fix decoding special characters (8d75d2a)

3.2.2 (2023-03-19)

Bug Fixes

  • generator: DateTime not convert to UTC (5f1f28b)
  • Read Dart reserved keyword from analyzer (f6a2b45)

3.2.1 (2023-03-19)

Bug Fixes

3.2.0 (2023-03-18)

Features

  • Migrate to generator helper (35486f4)

3.1.5 (2023-03-17)

Bug Fixes

3.1.4 (2023-03-15)

Bug Fixes

  • fix retry strategy not as expected (d327bcb), closes #161

3.1.3 (2023-03-14)

Bug Fixes

  • generator: main rethrow error (c536887)
  • engine: fix retry If failure, not as expected
  • engine: fix binary engine status retries not as expected. Thanks @blopker on #161

3.1.2 (2023-03-11)

Bug Fixes

  • Fix and optimize startup (253fb16)

3.1.1 (2023-03-10)

Bug Fixes

  • client: Fix missing error handler (8a32b6d)
  • generate: Fix datasource failed to generate dataproxy client. (8c5b7d7)

3.1.0 (2023-03-07)

Features

  • generator: Only support npm (41adccb)

Bug Fixes

  • generator: fix node package manager find index (a50d88f)
  • generator: fix node package manager not found on Windows (a233f59)
  • generator: fix parse prisma version error on Windows (7b16821)
  • generator: fix yarn query Prisma version is not json output (34b116c)

3.0.2 (2023-03-06)

Bug Fixes

  • engine: fixed logger definitions is empty throw error (4dc62f1)
  • generator: fixed Windows system cannot find the file specified (6446739)

3.0.1 (2023-03-05)

Bug Fixes

  • client: fixed prisma transaction type (2cf52ad)

3.0.0

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or tweeting about the release. 🌟

Note: Migration from 2.x to 3.x guide is available here.

3.0.1-beta+0

No changes.

3.0.0-beta+3

Bug Fixes

  • generate: fixed model delegate resolve GraphQL top-level field (35ebc6a)

2.6.2

  1. Fixed DateTime to String must be ISO8601 format error - #103
  2. Fixed PrismaNull being serialized as null error.

2.6.1

  1. Fixed generated freezed file has undefined class error - #96
  2. generated Prisma Dart Client is now null-safe
  3. Optimize the log parameter for createPrismaClient

2.6.0

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or tweeting about the release. 🌟

New requirements

Breaking change: You are now asked to install the freezed package:

dart pub add freezed -d

Breaking changes

All input classes types will be reset!

The Map input by forJson needs to follow the freezed rules, examples:

final PrismaNull $null = PrismaNull.fromJson({}); // An empty map must be entered to indicate PrismaNull

final UserWhereInput where = UserWhereInput.fromJson({
  'id': {
    'runtimeType': 'withInt', // The runtimeType must be entered, name is `UserWhereInput_id` factory name.
    'value': 1,
  },
});

PrismaUnion has been removed:

Before:

final data = UserCreateInput(
  name: PrismaUnion.zero("Seven"),
);

Now:

final data = CreateOneUserData.withUserCreateInput( // OR `withUserUncheckedCreateInput`
  UserCreateInput(
    name: "Seven",
  ),
);

Note: withUserCreateInput and withUserUncheckedCreateInput are generated by prisma_client.dart file.

Model delegates

All delegat methods input classes are now generated by freezed package, Example(create a user):

Before:

final user = await prisma.user.create(
  data: UserCreateInput(
    name: PrismaUnion.zero("Seven"),
  ),
);

Now:

final user = await prisma.user.create(
  data: CreateOneUserData.withUserUncheckedCreateInput(
    UserUncheckedCreateInput(
      name: 'Seven',
      email: '[email protected]',
    ),
  ),
);

Seems like it's getting troublesome?

We are preparing to support more Prisma functions in the future, such as REF query.

In addition, we are preparing for the next Dart 3, and we expect that in Dart 3, there is no need to run additional commands before compilation to complete the serialization of input and output types.

Since full input types are relatively cumbersome for web applications, we recommend using the fromJson method to create inputs.

Because the current input is the complete Prisma input type, it is expected to be improved in Dart 3. Currently, Dart 2 does not support union types. Our strategy is to create as many types as possible to meet all Prisma input requirements.

2.5.1

Support OrThrow methods

Prisma client now supports OrThrow methods.

final User user = await prisma.user.findUniqueOrThrow(...);
final Post post = await prisma.post.findFirstOrThrow(...);

2.5.0

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or tweeting about the release. 🌟

Breaking changes

Standalone Prisma client

Prisma client is now exported by orm package and exposes fromEngine constructor.

import 'package:orm/orm.dart';

final PrismaClient prisma = PrismaClient.fromEngine(...);

The generated prisma client now only extends model delegates, and creating a new Prisma client was changed from PrismaClient() to createPrismaClient:

Before:

final PrismaClient prisma = PrismaClient(...);

After:

final PrismaClient prisma = createPrismaClient(...);

Remove preview feature

All previews will be removed and existing Previews will be marked as stable in this release.

Preview will no longer be enabled in future releases, but release *.preview.{num} versions to mark

New features

Support queryRaw and executeRaw methods

Prisma client now supports queryRaw and executeRaw methods.

final PrismaClient prisma = createPrismaClient(...);

final List<Map<String, dynamic>> result = await prisma.$queryRaw('SELECT * FROM User');
final int affectedRows = await prisma.$executeRaw('DELETE FROM User');

Input classes support fromJson method

All input classes now support fromJson method.

final UserCreateInput input = UserCreateInput.fromJson(...);

Engines

  1. Prisma binary engines version updated to d6e67a83f971b175a593ccc12e15c4a757f93ffe
  2. Remote engines version updated to 4.8.0

2.4.7

  1. Now, Data proxy is stable.
  2. Getting platforms is now supported by prisma_get_platform.

2.4.6

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or tweeting about the release. 🌟

Query Engines

  • Data Proxy: Remote client version updated to 4.7.1.
  • Binary: Query engine version updated to 272861e07ab64f234d3ffc4094e32bd61775599c.

Bug Fixes

  • DMMF: The 'name' field of UniqueIndex should be nullable, not non-nullable as incorrectly defined. (#77)

Highlights

Interactive transactions are now Generally Available

Interactive transactions allow you to pass an async function into a $transaction, and execute any code you like between the individual Prisma Client queries. Once the application reaches the end of the function, the transaction is committed to the database. If your application encounters an error as the transaction is being executed, the function will throw an exception and automatically rollback the transaction.

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

2.4.5

2.4.4

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or tweeting about the release. 🌟

Engines

  • Update Prisma query engine to 694eea289a8462c80264df36757e4fdc129b1b32 (from 4.6.1)
  • Update Data Proxy remote prisma client to 4.6.1
  • Interactive Transactions for Prisma Data Proxy

Generator

  • Fix standard data type error calling fromJson

2.4.3

  • Fix generate command error format.

2.4.2

  • Fix init command generated SQLite database file url

2.4.1

Bug Fixes

  • Fix JSON-RPC error code on error data is nullable - #52

2.4.0

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or tweeting about the release. 🌟

Major improvements

Refactor Prisma config (environment), starting from 2.4.0, Prisma ORM for Dart no longer includes any third-party configurator.

What about the rc package?

The rc package was born for the Prisma ORM for Dart itself, and now the rc package has been refactored into a platform variable wrapper.

Production environment

The .prismarc file in the Dart project directory was loaded by default, and now lib/prisma_configurator.dart is loaded by default.

Previously configured Key in pubspec.yaml was prismarc, now it is production.

Before:

prisma:
    prismarc: {path}

after:

prisma:
    production: {path}

Development environment

The .dev.rc file was loaded by default, now it is prisma/development.dart.

Platform Environment

Prisma adaptively loads platform environment variables according to the current platform environment.

This means that the environment variables in the current system can be read in Dart VM, Flutter JIT, Dart JIT-compiled and Dart AOT-compiled. And it cannot be read in Dart Web and Flutter built app.

Flutter built app is an exception, even though it supports dart:io but there is no environment variable for the build environment in it.

2.3.1

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or Tweeting about the release. 🌟

Features

Logging (Preview)

Prisma ORM for Dart now supports logging as a preview feature. That means, it might have some flaws, but we hope you'll try it out and provide feedback.

To enable logging, you need to set the log property on the PrismaClient constructor and generate command:

prisma generate --preview=logging
PrismaClient(
  log: [
    PrismaLogDefinition(
      level: PrismaLogLevel.query,
      emit: PrismaLogEvent.stdout,
    ),
  ],
)
Subscribe to log events

You can subscribe to log events to perform custom actions when a log occurs.

prisma.$on([PrismaLogLevel.query], (e) {
  print(e);
});

2.3.0

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or Tweeting about the release. 🌟

Features

Development runtime configuration.

When using Prisma ORM to develop an app, you may want the development configuration to be inconsistent with the production environment (although this can be avoided by configuring the production environment separately), but there are always surprises.

For example, when we use Data Proxy, the client and CLI cannot be consistent, because the link address of Data Proxy cannot manage your database.

Now, you just need to add a .dev.rc to the root of your Dart project whose configuration will override the same configuration for prismarc and dotenv:

# .prismarc
DATABASE_URL: prisma://{location}.prisma-data.com/?api_key={Your API key}

# .dev.rc
DATABASE_URL: postgres://user:password@localhost:5432/mydb

For example in the configuration above, the actual CLI runtime uses postgres://user:password@localhost:5432/mydb, while in Prisma Client it uses prisma://{location}.prisma-data.com/?api_key ={Your API key}`.

Custom development runtime configuration

To customize the development runtime configuration file path, you can write in pubspec.yaml:

prisma:
  development: custom.devrc

Data Proxy (Preview)

Great, Prisma Dart now supports Prisma Data Proxy to access your database!

you just need to run:

dart run orm generate --data-proxy --preview=data-proxy

It can also be turned on from runtime configuration or dotenv:

# Configuration file
PRISMA_GENERATE_DATAPROXY = true

# Command line
dart run orm generate --preview=data-proxy
Custom remote client version.

If the default remote client version is not what you want, you can fix it by configuring:

PRISMA_CLIENT_DATA_PROXY_CLIENT_VERSION = "4.3.1"

Finalizer for PrismaClient

The PrismaClient now has a finalizer that will close the underlying database connection when the client is garbage collected.

Note: This feature is currently in preview state, you need to install 2.3.0 and above, and pass the --preview=finalizer option in the generate command to enable it. More information can be found in the 2.3.0@CLI change log.

CLI

generate command now supports --preview option to generate client for preview features.

E.g.

# Enable finalizer feature for generated PrismaClient.
dart run orm generate --preview=finalizer

Fixed bugs

2.2.3

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or Tweeting about the release. 🌟

Bug Fixes

  1. Fixed debian/ubuntu system distro match - #31
  2. Runtime - Fixed parse user facing error
  3. CLI - Fixed check engine version binary incomplete

2.2.2

Fixed generate schema not working (#29

2.2.1

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or Tweeting about the release. 🌟

Major improvements

Auto fix enum name and model name conflicts:

enum role {
 user
 admin
}

model user {
 id Int @id @default(autoincrement())
 role role
}

Before this release, the above schema would result in a role enum and a user model. This is not valid in Dart, so we now auto fix the enum name to Role and the model name to User.

Thanks to @moepoi

Bug fixes

  1. Fixed $transaction options not being passed.
  2. FIxed Using lowercase keywords in schema.prisma cannot generate clients correctly. - #26

Other

  • Update code_builder to ^4.3.0.

2.2.0

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or Tweeting about the release. 🌟

Major improvements:

Input object Types without PrismaUnion wrapper, Before:

final User user = await prisma.user.create(
   data: PrismaUnion(
      zero: UserCreateInput(name: 'odroe'),
   ),
);

After:

final User user = await prisma.user.create(
   data: UserCreateInput(name: 'odroe'),
);

Bug fixes:

  • Nullable fields generating broken field implementations - #23

Features:

  • Add precache command, Populate the Prisma engines cache of binary artifacts.

2.1.3

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or Tweeting about the release. 🌟

Major improvements:

  1. refactor PrismaClientKnownRequestError, Prisma Client throws a PrismaClientKnownRequestError exception if the query engine returns a known error related to the request - for example, a unique constraint violation. Reference 👉 PrismaClientKnownRequestError
  2. All exceptions on the client side will throw predictable errors,Reference 👉 PrismaClientKnownRequestError
  3. query_engine renamed to engine_core

Better error message

Take transaction errors as an example, before simply throwing PrismaServerError without any friendly prompts. Now:

PrismaClientUnknownRequestError:
Use the `prisma.$transaction()` API to run queries in a transaction.

Add the following to your `schema.prisma` file:

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

Read more about transactions in our documentation:
 - https://github.com/odroe/prisma-dart#qa
 - https://www.prisma.io/docs/concepts/components/prisma-client/transactions#interactive-transactions-in-preview

If the engine is not found:

PrismaClientInitializationError:
  message: Could not find query engine binary for current platform "macos" in query-engine path.

This probably happens, because you built Prisma Client on a different platform.

Searched Locations:
  - /Users/seven/workspace/prisma/example
  - /Users/seven/workspace/prisma/example/.dart_tool/prisma
  - /Users/seven/workspace/prisma/example/prisma
  - /Users/seven/workspace/prisma/example/.dart_tool/pub/bin/example

You already added the platform "macos" 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.

Please create an issue at https://github.com/odroe/prisma-dart/issues/new
  errorCode: null
  clientVersion: 2.1.2

$transaction options

prisma.$transaction now supports the following options:

final prisma = PrismaClient();
await prisma.$transaction((prisma) async {
   // ...
}, TransactionOptions(
   maxWait: 2000,
   timeout: 5000,
   isolationLevel: TransactionIsolationLevel.ReadUncommitted,
));

More details 👉 Interactive transactions

Bug fixes

  1. Fixed packageVersion not updating with version
  2. Fixed binary query engine not automatically searching when executable is specified
  3. Fixed binary query engine not automatically searching when specifying PRISMA_QUERY_ENGINE_BINARY environment variable

Engines version

c875e43600dfe042452e0b868f7a48b817b9640b

2.1.2

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or Tweeting about the release. 🌟

Bug fixes

  • Fix the problem of repeated operation of the lookup runtime configuration
  • Fix setting owerwrite datasources causing engine startup failure

Refactor

Refactored to owerwrite datasources to convert to engine readable settings

2.1.1

Support custom runtime configuration.

2.1.0

🌟 Help us spread the word about Prisma ORM for Dart by starring the repo or Tweeting about the release. 🌟

Major improvements:

Runtime configuration

Previously, use prisma.yaml to configure Prisma:

environment:
   DATABASE_URL: postgres://user:password@localhost:5432/mydb

Now, we have introduced a new configuration method, Runtime Configuration compatible with dotenv format:

# .prismarc
DATABASE_URL=postgres://user:password@localhost:5432/mydb

# Database host
DATABASE_HOST=postgres://user:password@localhost:5432
DATABASE_URL=${DATABASE_HOST}/mydb

If you have dotenv in mind, you just need to add the database URL configuration to .env:

DATABASE_URL=postgres://user:password@localhost:5432/mydb

For more usage of runtime configuration, please see 👉 https://pub.dev/packages/rc

Custom configuration

Now, you can customize your prisma project configuration in pubspec.yaml:

...
prisma:
   prismarc: path/a/b/c/custom.prismarc
   dotenv: path/a/b/c/custom.env
   schema: path/a/b/c/custom.prisma
...
Parameter Description Default
prismarc Custom runtime configuration path .prismarc
dotenv Custom dotenv path .env
schema Custom Prisma schema path prisma/schema.prisma

Custom engine path

Previously, the Prisma engine was downloaded into the .dart_tool/prisma directory, now you can customize it.

Custom engines path with runtime configuration
# Query binary engine
PRISMA_QUERY_ENGINE_BINARY(path) = custom-engines/query-engine

# Migration binary engine
PRISMA_MIGRATION_ENGINE_BINARY(path) = custom-engines/migration-engine

# Introspection binary engine
PRISMA_INTROSPECTION_ENGINE_BINARY(path) = custom-engines/introspection-engine

# Format binary engine
PRISMA_FMT_BINARY(path) = custom-engines/prisma-fmt
Custom engines path with dotenv
PRISMA_QUERY_ENGINE_BINARY=path/to/custom-engines/query-engine
PRISMA_MIGRATION_ENGINE_BINARY=path/to/custom-engines/migration-engine
PRISMA_INTROSPECTION_ENGINE_BINARY=path/to/custom-engines/introspection-engine
PRISMA_FMT_BINARY=path/to/custom-engines/prisma-fmt

Refactored package:orm/configure.dart

Previously, we have package:orm/configure.dart to configure Prisma, now we have refactored it to package:orm/prisma.dart:

import 'package:orm/configure.dart';

print(configure('DATABASE_URL'));

Now, you can use package:orm/configure.dart to configure Prisma:

import 'package:orm/configure.dart';

print(environment.DATABASE_URL);

Bug fixes:

  1. Fix map and throws binary errors - #16
  2. Problems using Model with relation - #14

Features:

  1. Generator generate import support show.
  2. Prisma CLI debug allow set to dotenv or runtime configuration.
  3. Prisma CLI debug print stack trace.