Skip to content

Commit

Permalink
Merge pull request #341 from medz/340-npx-prisma-generate-fails-with-…
Browse files Browse the repository at this point in the history
…orm-400

Fixed duplicate enum field name is `name`.
  • Loading branch information
Seven Du authored Feb 29, 2024
2 parents a807e68 + 9329aea commit 24e3eae
Show file tree
Hide file tree
Showing 20 changed files with 173,333 additions and 4 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# Prisma Client Dart v4.0.1

To install Prisma Client for Dart v4.0.1 run:

```bash
dart pub add orm:4.0.1
```

Or update your `pubspec.yaml` file:

```yaml
dependencies:
orm: 4.0.1
```
## What's Changed
- **Bug**(Generator): Fixed duplicate enum field name is `name`.

# Priama Client Dart v4.0.0

To install Prisma Client Dart v4.0.0 run:
Expand Down
6 changes: 6 additions & 0 deletions bin/src/generate_enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'generator.dart';
import 'utils/dart_style_fixer.dart';
import 'utils/reference.dart';

const _enumFieldNames = ['name'];

extension GenerateEnum on Generator {
Reference generateEnum(
String name, dmmf.TypeNamespace? namespace, bool isList) {
Expand Down Expand Up @@ -37,6 +39,10 @@ extension GenerateEnum on Generator {
for (final value in enum$.values) {
builder.values.add(EnumValue((builder) {
builder.name = value.propertyName;
if (_enumFieldNames.contains(builder.name)) {
builder.name = '${builder.name}\$';
}

builder.constructorName = _defaultConstructor.name;
builder.arguments.add(literalString(value));
}));
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ bun add prisma
Please run the following command to install `orm`:

```bash
dart pub add orm:4.0.0
dart pub add orm:4.0.1
```

Or add the following to your `pubspec.yaml` file:

```yaml
dependencies:
orm: ^4.0.0 // [!code focus]
orm: ^4.0.1 // [!code focus]
```
7 changes: 7 additions & 0 deletions i340/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
3 changes: 3 additions & 0 deletions i340/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
3 changes: 3 additions & 0 deletions i340/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version.
2 changes: 2 additions & 0 deletions i340/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.
30 changes: 30 additions & 0 deletions i340/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
5 changes: 5 additions & 0 deletions i340/bin/i340.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:i340/i340.dart' as i340;

void main(List<String> arguments) {
print('Hello world: ${i340.calculate()}!');
}
Binary file added i340/bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions i340/lib/i340.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int calculate() {
return 6 * 7;
}
5 changes: 5 additions & 0 deletions i340/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"prisma": "^5.10.2"
}
}
Loading

0 comments on commit 24e3eae

Please sign in to comment.