-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from odroe/23-nullable-fields-generating-broke…
…n-field-implementations Fixed #23 & input object types without `PrismaUnion` wrapper.
- Loading branch information
Showing
24 changed files
with
18,181 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: test | ||
on: [push, pull_request] | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
sdk: | ||
- stable | ||
- 2.18.0 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dart-lang/setup-dart@v1 | ||
with: | ||
sdk: ${{ matrix.sdk }} | ||
- name: Cache prisma engines | ||
uses: actions/cache@v3 | ||
with: | ||
path: .dart_tool/prisma | ||
key: ${{ runner.os }}-${{ runner.arch }}-prisma-engines-${{ hashFiles('**/lib/version.dart') }} | ||
- name: Install dependencies | ||
run: dart pub get | ||
- name: Pre-download engines | ||
run: dart run bin/orm.dart precache | ||
- name: Run tests | ||
run: dart test -r github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'package:args/command_runner.dart'; | ||
import 'package:orm/version.dart'; | ||
|
||
import '../binary_engine/binary_engine.dart'; | ||
import '../binary_engine/binary_engine_platform.dart'; | ||
import '../binary_engine/binray_engine_type.dart'; | ||
import '../utils/ansi_progress.dart'; | ||
|
||
class PrecacheCommand extends Command { | ||
@override | ||
String get description => | ||
'Populate the Prisma engines cache of binary artifacts.'; | ||
|
||
@override | ||
String get name => 'precache'; | ||
|
||
PrecacheCommand() { | ||
argParser.addMultiOption( | ||
'type', | ||
abbr: 't', | ||
help: 'The engine type to precache.', | ||
valueHelp: 'engine', | ||
allowed: BinaryEngineType.values.map((e) => e.name), | ||
defaultsTo: BinaryEngineType.values.map((e) => e.name), | ||
); | ||
} | ||
|
||
Iterable<BinaryEngineType> get types { | ||
final List<String> types = argResults?['type'] as List<String>; | ||
if (types.isEmpty) return BinaryEngineType.values; | ||
|
||
return BinaryEngineType.values | ||
.where((element) => types.contains(element.name)); | ||
} | ||
|
||
@override | ||
void run() async { | ||
for (final BinaryEngineType type in types) { | ||
final BinaryEngine binaryEngine = BinaryEngine( | ||
platform: BinaryEnginePlatform.current, | ||
type: type, | ||
version: binaryVersion, | ||
); | ||
|
||
if (!await binaryEngine.hasDownloaded) { | ||
await binaryEngine.download(AnsiProgress.createFutureHandler( | ||
'Download Prisma ${type.name} engine')); | ||
await Future.delayed(Duration(microseconds: 100)); | ||
continue; | ||
} | ||
|
||
print('Prisma ${type.name} engine is already downloaded.'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Four Prisma examples are available: | ||
|
||
- [simple](simple) - A simple Priama example. | ||
- [simple](simple) - A simple Priama example.] | ||
- [Readme example](readme_example) - An example that demonstrates how to use the `readme_example` package. Prisma schema used in [Readme#the-prisma-schema](../README.md#the-prisma-schema). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Files and directories created by pub. | ||
.dart_tool/ | ||
.packages | ||
|
||
# Conventional directory for build output. | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DATABASE_URL = "postgres://seven@localhost:5432/demo?schema=readme" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 | ||
|
||
- Initial version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:readme_example/readme_example.dart'; | ||
|
||
void main() async { | ||
final PrismaClient prisma = PrismaClient(); | ||
|
||
try { | ||
final String email = 'hello@odroe.com'; | ||
final User upsertUser = await prisma.user.upsert( | ||
where: UserWhereUniqueInput(email: email), | ||
create: UserCreateInput(email: email), | ||
update: UserUpdateInput( | ||
name: NullableStringFieldUpdateOperationsInput( | ||
set$: PrismaUnion.one(PrismaNull()), | ||
), | ||
), | ||
); | ||
|
||
final List<User> nullableUsers = await prisma.user.findMany( | ||
where: UserWhereInput( | ||
name: StringNullableFilter( | ||
equals: PrismaUnion.one(PrismaNull()), | ||
), | ||
), | ||
); | ||
|
||
print('Update or create user: \n ${upsertUser.toJson()}'); | ||
print(''); | ||
print( | ||
'Find nullable users: \n ${nullableUsers.map((e) => e.toJson()).toList()}'); | ||
} finally { | ||
await prisma.$disconnect(); | ||
} | ||
} |
Oops, something went wrong.