Updated to SDK 2.16.x

This commit is contained in:
thomashii 2022-04-23 12:21:39 +08:00
parent 9382529ad7
commit 47cbaacef2
136 changed files with 1046 additions and 602 deletions

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.1.2

View file

@ -4,7 +4,7 @@ version: 6.0.0
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/auth
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^6.0.0
charcode: ^1.2.0

View file

@ -1,5 +1,13 @@
# Change Log
## 6.0.0
* Updated to SDK 2.16.x
## 5.0.0
* Skipped release
## 4.1.0
* Updated linter to `package:lints`

View file

@ -99,7 +99,7 @@ void main() async {
//
// Use `confirmPopupAuthentication`, which is bundled with
// `package:angel_auth`.
var user = req.container!.make<User>()!;
var user = req.container!.make<User>();
res.write('Your user info: ${user.toJson()}\n\n');
res.write('Your JWT: $jwt');
await res.close();

View file

@ -1,13 +1,13 @@
name: angel3_auth_oauth2
version: 4.1.0
version: 6.0.0
description: Angel3 library for authenticating users with external identity providers via OAuth2.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/auth_oauth2
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_auth: ^4.1.0
angel3_framework: ^4.2.0
angel3_auth: ^6.0.0
angel3_framework: ^6.0.0
http_parser: ^4.0.0
oauth2: ^2.0.0
dev_dependencies:

View file

@ -1,4 +0,0 @@
language: dart
dart:
- stable
- dev

View file

@ -1,5 +1,13 @@
# Change Log
## 6.0.0
* Updated to SDK 2.16.x
## 5.0.0
* Skipped release
## 4.0.3
* Updated linter to `package:lints`

View file

@ -1,12 +1,12 @@
name: angel3_cache
version: 4.0.3
version: 6.0.0
description: A service that provides HTTP caching to the response data for Angel3
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/cache
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^4.2.0
angel3_framework: ^6.0.0
collection: ^1.15.0
meta: ^1.4.0
pool: ^1.5.0

View file

@ -1,4 +0,0 @@
language: dart
dart:
- dev
- stable

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.2.0

View file

@ -4,7 +4,7 @@ description: A browser, mobile and command line based client that supports query
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/client
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_http_exception: ^6.0.0
belatuk_json_serializer: ^5.0.0

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.1.0

View file

@ -4,7 +4,7 @@ description: Automatic YAML application configuration loader for Angel 3, with .
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/configuration
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^6.0.0
belatuk_merge_map: ^3.0.0

View file

@ -2,7 +2,7 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
* Removed `error`
## 5.0.0

View file

@ -4,7 +4,7 @@ description: Angel3 hierarchical DI container, and pluggable backends for reflec
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
collection: ^1.15.0
quiver: ^3.0.1

View file

@ -2,7 +2,7 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0

View file

@ -4,7 +4,7 @@ description: Codegen support for using pkg:reflectable with pkg:angel3_container
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container_generator
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_container: ^6.0.0
reflectable: ^3.0.4

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.1.0

View file

@ -4,7 +4,7 @@ description: Angel3 CORS middleware. Ported from expressjs/cors to Angel3 framew
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/cors
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^6.0.0
dev_dependencies:

View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>

View file

@ -1,4 +0,0 @@
language: dart
dart:
- dev
- stable

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.1.0

View file

@ -4,7 +4,7 @@ description: Angel service that persists data to a file on disk, stored as a JSO
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/file_service
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^6.0.0
file: ^6.1.1

View file

@ -1,6 +0,0 @@
language: dart
dart:
- dev
- stable
before_script: chmod +x ./tool/travis.sh
script: ./tool/travis.sh

View file

@ -2,7 +2,7 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
* Updated `container` to non nullable
* Updated `angel` to non nullable
* Updated `logger` to non nullable
@ -10,7 +10,7 @@
## 5.0.0
* No release. Skipped
* Skipped release
## 4.2.4

View file

@ -4,7 +4,7 @@ description: A high-powered HTTP server extensible framework with dependency inj
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_container: ^6.0.0
angel3_http_exception: ^6.0.0

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -e
pub run test --timeout 5s
ANGEL_ENV=production pub run test --timeout 5s

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.3.0

View file

@ -4,7 +4,7 @@ description: Supports hot reloading/hot code push of Angel3 servers on file chan
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/hot
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^6.0.0
angel3_websocket: ^6.0.0

View file

@ -1,5 +1,17 @@
# Change Log
## 6.0.0
* Updated to SDK 2.16.x
## 5.0.0
* Skipped release
## 4.0.0
* No release. Skipped
## 3.0.0
* Migrated to support Dart SDK 2.12.x NNBD

View file

@ -35,7 +35,7 @@ In your `pubspec.yaml`:
```yaml
dependencies:
angel3_html: ^3.0.0
angel3_html: ^6.0.0
```
## Usage

View file

@ -1,16 +1,39 @@
name: angel3_html
version: 3.0.0
version: 6.0.0
description: Support for rendering html_builder AST's as responses in Angel.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/html_builder
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^4.0.0
angel3_framework: ^6.0.0
belatuk_html_builder: ^3.0.0
dev_dependencies:
angel3_test: ^4.0.0
angel3_test: ^6.0.0
html: ^0.15.0
logging: ^1.0.1
test: ^1.17.0
lints: ^1.0.0
lints: ^1.0.0
dependency_overrides:
angel3_container:
path: ../container/angel_container
angel3_framework:
path: ../framework
angel3_test:
path: ../test
angel3_websocket:
path: ../websocket
angel3_http_exception:
path: ../http_exception
angel3_client:
path: ../client
angel3_auth:
path: ../auth
angel3_validate:
path: ../validate
angel3_mock_request:
path: ../mock_request
angel3_model:
path: ../model
angel3_route:
path: ../route

View file

@ -3,7 +3,7 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
* Removed `error`
## 5.0.0

View file

@ -4,6 +4,6 @@ description: Exception class that can be serialized to JSON and serialized to cl
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/http_exception
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dev_dependencies:
lints: ^1.0.0

View file

@ -1,2 +0,0 @@
language: dart
script: bash ./travis.sh

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.3.1

View file

@ -4,7 +4,7 @@ description: Angel support for the Jael templating engine, similar to Blade or L
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/jael/angel_jael
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^6.0.0
jael3: ^5.0.0

View file

@ -2,7 +2,7 @@
## 5.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 4.2.0

View file

@ -4,7 +4,7 @@ description: A simple server-side HTML templating engine for Dart. Comparable t
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/jael/jael
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
args: ^2.0.0
charcode: ^1.0.0

View file

@ -4,14 +4,14 @@ description: Language Server Protocol implementation for the Jael templating eng
homepage: https://github.com/angel-dart/vscode
publish_to: none
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
args: ^2.1.1
# dart_language_server: ^0.1.16
file: ^6.1.2
io: ^1.0.0
jael3: ^4.2.0
jael3_preprocessor: ^4.2.0
jael3_preprocessor: ^5.0.0
json_rpc_2: ^3.0.1
logging: ^1.0.1
path: ^1.8.0

View file

@ -2,7 +2,7 @@
## 5.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 4.2.0

View file

@ -4,7 +4,7 @@ description: A pre-processor for resolving blocks and includes within Jael templ
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/jael/jael_preprocessor
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
file: ^6.1.0
jael3: ^6.0.0

View file

@ -3,7 +3,7 @@ version: 2.0.0
description: Experimental virtual DOM/SPA engine built on Jael3. Supports SSR.
publish_to: none
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
build: ^2.0.2
build_config: ^1.0.0

View file

@ -1,5 +1,21 @@
# Change Log
## 6.0.0
* Updated to SDK 2.16.x
## 5.0.0
* Skipped release
## 4.0.0
* Skipped release
## 3.0.0
* Skipped release
## 2.0.1
* Fixed Jinja view rendering issue

View file

@ -1,14 +1,14 @@
name: angel3_jinja
version: 2.0.1
version: 6.0.0
description: A service that renders Jinja2 template into HTML view for Angel3. Ported from Python to Dart.
homepage: https://github.com/dukefirehawk/angel/tree/master/packages/jinja
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^4.2.0
angel3_framework: ^6.0.0
jinja: ^0.3.4
dev_dependencies:
angel3_test: ^4.0.0
angel3_test: ^6.0.0
path: ^1.8.0
test: ^1.17.5
lints: ^1.0.0

View file

@ -1,5 +1,13 @@
# Change Log
## 6.0.0
* Updated to SDK 2.16.x
## 5.0.0
* Skipped release
## 4.1.0
* Updated linter to `package:lints`

View file

@ -1,15 +1,15 @@
name: angel3_markdown
version: 4.1.0
version: 6.0.0
description: Angel3 Markdown view generator. Write static sites, with no build step.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/markdown
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^4.2.0
angel3_framework: ^6.0.0
file: ^6.1.2
markdown: ^4.0.0
dev_dependencies:
angel3_test: ^4.0.0
angel3_test: ^6.0.0
lints: ^1.0.0
test: ^1.17.0

View file

@ -2,19 +2,19 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.0.0
* No release. Skipped
* Skipped release
## 3.0.0
* No release. Skipped
* Skipped release
## 2.1.0

View file

@ -4,7 +4,7 @@ description: Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/mock_request
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
charcode: ^1.2.0
dev_dependencies:

View file

@ -2,15 +2,15 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.0.0
* No release. Skipped
* Skipped release
## 3.1.1

View file

@ -4,6 +4,6 @@ description: Angel3 basic data model class, no longer with the added weight of t
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/model
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dev_dependencies:
lints: ^1.0.0

View file

@ -2,15 +2,15 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.0.0
* No release. Skipped
* Skipped release
## 3.1.0

View file

@ -4,7 +4,7 @@ description: MongoDB-enabled services for the Angel3 framework. Well-tested.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/mongo
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^6.0.0
belatuk_json_serializer: ^5.0.0

View file

@ -1,5 +1,17 @@
# Change Log
## 6.0.0
* Updated to SDK 2.16.x
## 5.0.0
* Skipped release
## 4.0.0
* Skipped release
## 3.1.1
* Updated README

View file

@ -1,12 +1,12 @@
name: angel3_mustache
version: 3.1.1
version: 6.0.0
description: A service that renders Mustache template into HTML view for Angel3
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/mustache
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^4.2.0
angel3_framework: ^6.0.0
file: ^6.1.2
mustache_template: ^2.0.0
path: ^1.8.0

View file

@ -1,5 +1,13 @@
# Change Log
## 6.0.0
* Updated to SDK 2.16.x
## 5.0.0
* Skipped release
## 4.1.1
* Updated README

View file

@ -1,18 +1,18 @@
name: angel3_oauth2
version: 4.1.1
version: 6.0.0
description: A class containing handlers that can be used within Angel to build a spec-compliant OAuth 2.0 server.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/oauth2
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^4.2.0
angel3_http_exception: ^3.0.0
angel3_framework: ^6.0.0
angel3_http_exception: ^6.0.0
crypto: ^3.0.1
collection: ^1.15.0
dev_dependencies:
angel3_validate: ^4.0.0
angel3_test: ^4.0.0
angel3_validate: ^6.0.0
angel3_test: ^6.0.0
logging: ^1.0.1
oauth2: ^2.0.0
lints: ^1.0.0

View file

@ -1,10 +0,0 @@
language: dart
script: bash tool/.travis.sh
before_script:
- psql -c 'create database angel_orm_test;' -U postgres
- psql -c 'create database angel_orm_service_test;' -U postgres
- psql -c "CREATE USER angel_orm WITH PASSWORD 'angel_orm';" -U postgres
services:
- postgresql
addons:
postgresql: "9.4"

View file

@ -1,4 +1,4 @@
# ORM
# Angel3 ORM
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_orm?include_prereleases)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
@ -10,7 +10,7 @@ Source-generated ORM for use with the [Angel3 framework](https://github.com/duke
Documentation for migrations can be found here:
[ORM Migration](https://angel3-docs.dukefirehawk.com/guides/orm/migrations)
- [ORM](#orm)
- [Angel3 ORM](#angel3-orm)
- [Usage](#usage)
- [Models](#models)
- [Example](#example)
@ -27,9 +27,9 @@ You'll need these dependencies in your `pubspec.yaml`:
```yaml
dependencies:
angel3_orm: ^4.0.0
angel3_orm: ^6.0.0
dev_dependencies:
angel3_orm_generator: ^4.0.0
angel3_orm_generator: ^6.0.0
build_runner: ^2.0.0
```

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.0.4

View file

@ -4,7 +4,7 @@ description: Database migration runtime for Angel3 ORM. Use this package to defi
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_migration
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_orm: ^6.0.0
dev_dependencies:

View file

@ -2,11 +2,12 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
* Updated to use `mysql_client` package
## 5.0.0
* No release. Skipped
* Skipped release
## 4.1.2

View file

@ -4,35 +4,40 @@ import 'package:angel3_migration_runner/postgres.dart';
import 'package:angel3_migration_runner/mysql.dart';
import 'package:angel3_orm/angel3_orm.dart';
import 'package:postgres/postgres.dart';
import 'package:mysql1/mysql1.dart';
import 'package:mysql_client/mysql_client.dart';
import 'todo.dart';
var postgresqlMigrationRunner = PostgresMigrationRunner(
PostgreSQLConnection('127.0.0.1', 5432, 'demo',
username: 'demouser', password: 'demo123'),
migrations: [
UserMigration(),
TodoMigration(),
FooMigration(),
],
);
void main(List<String> args) async {
var postgresqlMigrationRunner = PostgresMigrationRunner(
PostgreSQLConnection('localhost', 5432, 'demo',
username: 'demouser', password: 'demo123'),
migrations: [
UserMigration(),
TodoMigration(),
FooMigration(),
],
);
var mysqlMigrationRunner = MysqlMigrationRunner(
ConnectionSettings(
host: 'localhost',
var mySQLConn = await MySQLConnection.createConnection(
host: "localhost",
port: 3306,
user: 'demouser',
password: 'demo123',
db: 'demo'),
migrations: [
UserMigration(),
TodoMigration(),
FooMigration(),
],
);
databaseName: "orm_test",
userName: "test",
password: "Test123*",
secure: false);
void main(List<String> args) => runMigrations(postgresqlMigrationRunner, args);
var mysqlMigrationRunner = MysqlMigrationRunner(
mySQLConn,
migrations: [
UserMigration(),
TodoMigration(),
FooMigration(),
],
);
runMigrations(postgresqlMigrationRunner, args);
}
class FooMigration extends Migration {
@override

View file

@ -2,7 +2,7 @@ import 'dart:async';
import 'dart:collection';
import 'package:angel3_migration/angel3_migration.dart';
import 'package:logging/logging.dart';
import 'package:mysql1/mysql1.dart';
import 'package:mysql_client/mysql_client.dart';
import '../runner.dart';
import '../util.dart';
import 'schema.dart';
@ -11,12 +11,11 @@ class MysqlMigrationRunner implements MigrationRunner {
final _log = Logger('PostgresMigrationRunner');
final Map<String, Migration> migrations = {};
final ConnectionSettings settings;
final Queue<Migration> _migrationQueue = Queue();
late MySqlConnection connection;
final MySQLConnection connection;
bool _connected = false;
MysqlMigrationRunner(this.settings,
MysqlMigrationRunner(this.connection,
{Iterable<Migration> migrations = const [], bool connected = false}) {
if (migrations.isNotEmpty == true) migrations.forEach(addMigration);
_connected = connected == true;
@ -35,11 +34,12 @@ class MysqlMigrationRunner implements MigrationRunner {
}
if (!_connected) {
connection = await MySqlConnection.connect(settings);
//connection = await MySQLConnection.connect(settings);
await connection.connect();
_connected = true;
}
await connection.query('''
await connection.execute('''
CREATE TABLE IF NOT EXISTS "migrations" (
id serial,
batch integer,
@ -56,8 +56,8 @@ class MysqlMigrationRunner implements MigrationRunner {
@override
Future up() async {
await _init();
var r = await connection.query('SELECT path from migrations;');
var existing = r.expand((x) => x).cast<String>();
var r = await connection.execute('SELECT path from migrations;');
var existing = r.rows.cast<String>(); //.expand((x) => x).cast<String>();
var toRun = <String>[];
migrations.forEach((k, v) {
@ -65,9 +65,10 @@ class MysqlMigrationRunner implements MigrationRunner {
});
if (toRun.isNotEmpty) {
var r = await connection.query('SELECT MAX(batch) from migrations;');
var rTmp = r.toList();
var curBatch = (rTmp[0][0] ?? 0) as int;
var r = await connection.execute('SELECT MAX(batch) from migrations;');
var rTmp = r.rows.first; //r.toList();
var curBatch =
int.tryParse(rTmp.colAt(0) ?? "0") ?? 0; //(rTmp[0][0] ?? 0) as int;
var batch = curBatch + 1;
for (var k in toRun) {
@ -76,11 +77,11 @@ class MysqlMigrationRunner implements MigrationRunner {
migration.up(schema);
_log.info('Added "$k" into "migrations" table.');
await schema.run(connection).then((_) {
return connection.transaction((ctx) async {
var result = await ctx.query(
return connection.transactional((ctx) async {
var result = await ctx.execute(
"INSERT INTO MIGRATIONS (batch, path) VALUES ($batch, '$k')");
return result.affectedRowCount;
return result.affectedRows;
});
//return connection.execute(
// 'INSERT INTO MIGRATIONS (batch, path) VALUES ($batch, \'$k\');');
@ -97,13 +98,14 @@ class MysqlMigrationRunner implements MigrationRunner {
Future rollback() async {
await _init();
var r = await connection.query('SELECT MAX(batch) from migrations;');
var rTmp = r.toList();
var curBatch = (rTmp[0][0] ?? 0) as int;
var r = await connection.execute('SELECT MAX(batch) from migrations;');
var rTmp = r.rows.first; //r.toList();
var curBatch =
int.tryParse(rTmp.colAt(0) ?? "0") ?? 0; //(rTmp[0][0] ?? 0) as int;
r = await connection
.query('SELECT path from migrations WHERE batch = $curBatch;');
var existing = r.expand((x) => x).cast<String>();
.execute('SELECT path from migrations WHERE batch = $curBatch;');
var existing = r.rows.cast<String>(); //r.expand((x) => x).cast<String>();
var toRun = <String>[];
migrations.forEach((k, v) {
@ -118,7 +120,7 @@ class MysqlMigrationRunner implements MigrationRunner {
_log.info('Removed "$k" from "migrations" table.');
await schema.run(connection).then((_) {
return connection
.query('DELETE FROM migrations WHERE path = \'$k\';');
.execute('DELETE FROM migrations WHERE path = \'$k\';');
});
}
} else {
@ -130,8 +132,8 @@ class MysqlMigrationRunner implements MigrationRunner {
Future reset() async {
await _init();
var r = await connection
.query('SELECT path from migrations ORDER BY batch DESC;');
var existing = r.expand((x) => x).cast<String>();
.execute('SELECT path from migrations ORDER BY batch DESC;');
var existing = r.rows.cast<String>(); //r.expand((x) => x).cast<String>();
var toRun = existing.where(migrations.containsKey).toList();
if (toRun.isNotEmpty) {
@ -142,7 +144,7 @@ class MysqlMigrationRunner implements MigrationRunner {
_log.info('Removed "$k" from "migrations" table.');
await schema.run(connection).then((_) {
return connection
.query('DELETE FROM migrations WHERE path = \'$k\';');
.execute('DELETE FROM migrations WHERE path = \'$k\';');
});
}
} else {

View file

@ -2,7 +2,7 @@ import 'dart:async';
import 'package:angel3_migration/angel3_migration.dart';
import 'package:angel3_migration_runner/src/mysql/table.dart';
import 'package:logging/logging.dart';
import 'package:mysql1/mysql1.dart';
import 'package:mysql_client/mysql_client.dart';
class MysqlSchema extends Schema {
final _log = Logger('MysqlSchema');
@ -14,17 +14,17 @@ class MysqlSchema extends Schema {
factory MysqlSchema() => MysqlSchema._(StringBuffer(), 0);
Future<int> run(MySqlConnection connection) async {
Future<int> run(MySQLConnection connection) async {
//return connection.execute(compile());
var result = await connection.transaction((ctx) async {
var result = await connection.transactional((ctx) async {
var sql = compile();
var result = await ctx.query(sql).catchError((e) {
var result = await ctx.execute(sql).catchError((e) {
_log.severe('Failed to run query: [ $sql ]', e);
});
return result.affectedRowCount;
return result.affectedRows.toInt();
});
return (result is int) ? result : 0;
return result;
}
String compile() => _buf.toString();

View file

@ -4,14 +4,14 @@ description: Command-line based database migration runner for Angel3's ORM.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_migration_runner
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_migration: ^6.0.0
angel3_orm: ^6.0.0
args: ^2.1.0
charcode: ^1.2.0
postgres: ^2.4.0
mysql1: ^0.19.2
mysql_client: ^0.0.11
logging: ^1.0.0
dev_dependencies:
lints: ^1.0.0

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.1.0

View file

@ -16,7 +16,7 @@ abstract class QueryValues {
String compileInsert(Query query, String tableName) {
var data = Map<String, dynamic>.from(toMap());
var now = DateTime.now();
var now = DateTime.now().toUtc();
if (data.containsKey('created_at') && data['created_at'] == null) {
data['created_at'] = now;
}
@ -71,7 +71,7 @@ abstract class QueryValues {
if (data.isEmpty) {
return '';
}
var now = DateTime.now();
var now = DateTime.now().toUtc();
if (data.containsKey('created_at') && data['created_at'] == null) {
data.remove('created_at');
}

View file

@ -4,7 +4,7 @@ description: Runtime support for Angel3 ORM. Includes base classes for queries.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
charcode: ^1.2.0
intl: ^0.17.0

View file

@ -2,11 +2,11 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.3.0

View file

@ -240,8 +240,9 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
..type = refer('List')))
..body = Block((b) {
var i = 0;
var args = <String, Expression>{};
// Build the argurments for model
var args = <String, Expression>{};
for (var field in ctx.effectiveFields) {
var fType = field.type;
Reference type = convertTypeReference(field.type);
@ -249,14 +250,10 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
type = refer('int');
}
// Reverted since as `continue` for `RelationshipFieldImp` will
// cause `_index` requires +2 or +3 in order to map to the correct
// fields
//
//literalNum(i++);
//var expr = (refer('row').index(CodeExpression(Code('_index++'))));
// Generated Code: row[i]
var expr = (refer('row').index(literalNum(i++)));
if (isSpecialId(ctx, field)) {
// Generated Code: row[i].toString()
expr = expr.property('toString').call([]);
} else if (field is RelationFieldImpl) {
continue;
@ -272,7 +269,11 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
var isNull = expr.equalTo(literalNull);
expr = isNull.conditional(literalNull,
type.property('values').index(expr.asA(refer('int'))));
} else if (fType.isDartCoreBool) {
// Generated Code: mapToBool(row[i])
expr = refer('mapToBool').call([expr]);
} else {
// Generated Code: (row[i] as type?)
expr = expr.asA(type);
}
expr = refer('fields').property('contains').call([

View file

@ -4,7 +4,7 @@ description: Code generators for Angel3 ORM. Generates query builder classes.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_generator
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_model: ^6.0.0
angel3_serialize: ^6.0.0

View file

@ -1,26 +1,26 @@
# Change Log
## 6.0.0-beta.1
## 6.0.0
* Updated to min SDK 2.15.x
* Upgrade to use `mysql1` driver
* Added support for MariaDB 10.2.x
* Updated to SDK 2.16.x
* Added support for MariaDB 10.2.x with `mysql1` driver
* Added support for MySQL 8.x.x with `mysql_client` driver
## 5.0.0
* No release. Skipped
* Skipped release
## 4.0.0
* No release. Skipped
* Skipped release
## 3.0.0
* No release. Skipped
* Skipped release
## 2.0.0
* No release. Skipped
* Skipped release
## 2.0.0-beta.3

View file

@ -5,13 +5,49 @@
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_mysql/LICENSE)
Mysql support for Angel3 ORM.
This package contains the SQL Executor required by Angel3 ORM to work with MySQL and MariaDB respectively. In order to better support the differences in MySQL and MariaDb underlying protocols, two different drives have to be used. For MariaDb 10.2.x, `mysql1` driver provides the best results, while `mysql_client` driver handles MySQL 8.x.x without issues.
## Supported database
* MariaDbExecutor (stable)
* MySqlExecutor (beta)
* MySQL 8.0 or later
* MariaDb 10.2.1 or later
## Supported database version
**Note** ORM for MySQL requires support for `WITH` SQL Syntax
* MySQL 8.x
* MariaDb 10.2.x
For documentation about the ORM, head to the main project repo: <https://github.com/dukefirehawk/angel/tree/master/packages/orm>
**Note** MySQL below version 8.0 and MariaDB below version 10.2 are not supported as Angel3 ORM requires common table expressions (CTE).
## Connecting to MySQL database 8.x.x
```dart
import 'package:mysql_client/mysql_client.dart';
var settings = ConnectionSettings(
host: 'localhost',
port: 3306,
db: 'orm_test',
user: 'Test',
password: 'Test123*');
var connection = await MySqlConnection.connect(settings);
var logger = Logger('orm_mysql');
var executor = MariaDbExecutor(connection, logger: logger);
```
## Connecting to MariaDB database 10.2.x
```dart
import 'package:mysql1/mysql1.dart';
var connection = await MySQLConnection.createConnection(
host: "localhost",
port: 3306,
databaseName: "orm_test",
userName: "test",
password: "Test123*",
secure: false);
var logger = Logger('orm_mysql');
await connection.connect(timeoutMs: 10000);
var executor = MySqlExecutor(connection, logger: logger);
```

View file

@ -1,15 +1,25 @@
import 'dart:io';
import 'package:angel3_migration/angel3_migration.dart';
import 'package:angel3_orm/angel3_orm.dart';
import 'package:angel3_orm_mysql/angel3_orm_mysql.dart';
import 'package:angel3_serialize/angel3_serialize.dart';
//import 'package:galileo_sqljocky5/sqljocky.dart';
import 'package:logging/logging.dart';
import 'package:mysql_client/mysql_client.dart';
import 'package:mysql1/mysql1.dart';
import 'package:logging/logging.dart';
import 'package:optional/optional.dart';
part 'main.g.dart';
void main() async {
hierarchicalLoggingEnabled = true;
//hierarchicalLoggingEnabled = true;
//await mariaDBExample();
await mysqlExample();
exit(0);
}
Future<void> mariaDBExample() async {
Logger.root
..level = Level.ALL
..onRecord.listen(print);
@ -22,12 +32,47 @@ void main() async {
password: 'Test123*');
var connection = await MySqlConnection.connect(settings);
print("Connected to MariaDb");
var logger = Logger('orm_mysql');
var executor = MariaDbExecutor(connection, logger: logger);
var query = TodoQuery();
query.values
..text = 'Clean your room!'
..updatedAt = DateTime.now().toUtc()
..isComplete = false;
var todo = await query.insert(executor);
print(todo.value.toJson());
var query2 = TodoQuery()..where!.id.equals(todo.value.idAsInt);
var todo2 = await query2.getOne(executor);
print(todo2.value.toJson());
print(todo == todo2);
}
Future<void> mysqlExample() async {
Logger.root
..level = Level.ALL
..onRecord.listen(print);
var connection = await MySQLConnection.createConnection(
host: "localhost",
port: 3306,
databaseName: "orm_test",
userName: "test",
password: "Test123*",
secure: false);
print("Connected to MySQL");
var logger = Logger('orm_mysql');
await connection.connect(timeoutMs: 10000);
var executor = MySqlExecutor(connection, logger: logger);
var query = TodoQuery();
query.values
..text = 'Clean your room!'
..updatedAt = DateTime.now().toUtc()
..isComplete = false;
var todo = await query.insert(executor);

View file

@ -11,10 +11,10 @@ class TodoMigration extends Migration {
void up(Schema schema) {
schema.create('todos', (table) {
table.serial('id').primaryKey();
table.boolean('is_complete').defaultsTo(false);
table.varChar('text');
table.timeStamp('created_at');
table.timeStamp('updated_at');
table.boolean('is_complete').defaultsTo(false);
table.varChar('text', length: 255);
});
}
@ -29,7 +29,7 @@ class TodoMigration extends Migration {
// **************************************************************************
class TodoQuery extends Query<Todo, TodoQueryWhere> {
TodoQuery({Set<String>? trampoline}) {
TodoQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
trampoline ??= <String>{};
trampoline.add(tableName);
_where = TodoQueryWhere(this);
@ -38,6 +38,8 @@ class TodoQuery extends Query<Todo, TodoQueryWhere> {
@override
final TodoQueryValues values = TodoQueryValues();
List<String> _selectedFields = [];
TodoQueryWhere? _where;
@override
@ -52,7 +54,15 @@ class TodoQuery extends Query<Todo, TodoQueryWhere> {
@override
List<String> get fields {
return const ['id', 'is_complete', 'text', 'created_at', 'updated_at'];
const _fields = ['id', 'created_at', 'updated_at', 'is_complete', 'text'];
return _selectedFields.isEmpty
? _fields
: _fields.where((field) => _selectedFields.contains(field)).toList();
}
TodoQuery select(List<String> selectedFields) {
_selectedFields = selectedFields;
return this;
}
@override
@ -65,44 +75,46 @@ class TodoQuery extends Query<Todo, TodoQueryWhere> {
return TodoQueryWhere(this);
}
static Todo? parseRow(List row) {
if (row.every((x) => x == null)) return null;
Optional<Todo> parseRow(List row) {
if (row.every((x) => x == null)) {
return Optional.empty();
}
var model = Todo(
id: row[0].toString(),
isComplete: (row[1] as int?) != 0,
text: (row[2] as String?),
createdAt: (row[3] as DateTime?),
updatedAt: (row[4] as DateTime?));
return model;
id: fields.contains('id') ? row[0].toString() : null,
createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null,
updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null,
isComplete: fields.contains('is_complete') ? mapToBool(row[3]) : null,
text: fields.contains('text') ? (row[4] as String?) : null);
return Optional.of(model);
}
@override
Optional<Todo> deserialize(List row) {
return Optional.ofNullable(parseRow(row));
return parseRow(row);
}
}
class TodoQueryWhere extends QueryWhere {
TodoQueryWhere(TodoQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
isComplete = BooleanSqlExpressionBuilder(query, 'is_complete'),
text = StringSqlExpressionBuilder(query, 'text'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at'),
isComplete = BooleanSqlExpressionBuilder(query, 'is_complete'),
text = StringSqlExpressionBuilder(query, 'text');
final NumericSqlExpressionBuilder<int> id;
final BooleanSqlExpressionBuilder isComplete;
final StringSqlExpressionBuilder text;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
final BooleanSqlExpressionBuilder isComplete;
final StringSqlExpressionBuilder text;
@override
List<SqlExpressionBuilder> get expressionBuilders {
return [id, isComplete, text, createdAt, updatedAt];
return [id, createdAt, updatedAt, isComplete, text];
}
}
@ -112,21 +124,11 @@ class TodoQueryValues extends MapQueryValues {
return {};
}
int? get id {
return (values['id'] as int?);
String? get id {
return (values['id'] as String?);
}
set id(int? value) => values['id'] = value;
bool? get isComplete {
return (values['is_complete'] as bool?);
}
set isComplete(bool? value) => values['is_complete'] = value;
String? get text {
return (values['text'] as String?);
}
set text(String? value) => values['text'] = value;
set id(String? value) => values['id'] = value;
DateTime? get createdAt {
return (values['created_at'] as DateTime?);
}
@ -137,11 +139,21 @@ class TodoQueryValues extends MapQueryValues {
}
set updatedAt(DateTime? value) => values['updated_at'] = value;
bool? get isComplete {
return (values['is_complete'] as bool?);
}
set isComplete(bool? value) => values['is_complete'] = value;
String? get text {
return (values['text'] as String?);
}
set text(String? value) => values['text'] = value;
void copyFrom(Todo model) {
isComplete = model.isComplete;
text = model.text;
createdAt = model.createdAt;
updatedAt = model.updatedAt;
isComplete = model.isComplete;
text = model.text;
}
}
@ -153,53 +165,61 @@ class TodoQueryValues extends MapQueryValues {
class Todo extends _Todo {
Todo(
{this.id,
this.isComplete = false,
this.text,
this.createdAt,
this.updatedAt});
this.updatedAt,
this.isComplete = false,
this.text});
/// A unique identifier corresponding to this item.
@override
String? id;
/// The time at which this item was created.
@override
DateTime? createdAt;
/// The last time at which this item was updated.
@override
DateTime? updatedAt;
@override
final String? id;
bool? isComplete;
@override
final bool? isComplete;
@override
final String? text;
@override
final DateTime? createdAt;
@override
final DateTime? updatedAt;
String? text;
Todo copyWith(
{String? id,
bool? isComplete,
String? text,
DateTime? createdAt,
DateTime? updatedAt}) {
DateTime? updatedAt,
bool? isComplete,
String? text}) {
return Todo(
id: id ?? this.id,
isComplete: isComplete ?? this.isComplete,
text: text ?? this.text,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
updatedAt: updatedAt ?? this.updatedAt,
isComplete: isComplete ?? this.isComplete,
text: text ?? this.text);
}
@override
bool operator ==(other) {
return other is _Todo &&
other.id == id &&
other.isComplete == isComplete &&
other.text == text &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
other.updatedAt == updatedAt &&
other.isComplete == isComplete &&
other.text == text;
}
@override
int get hashCode {
return hashObjects([id, isComplete, text, createdAt, updatedAt]);
return hashObjects([id, createdAt, updatedAt, isComplete, text]);
}
@override
String toString() {
return 'Todo(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, isComplete=$isComplete, text=$text)';
}
Map<String, dynamic> toJson() {
@ -211,39 +231,56 @@ class Todo extends _Todo {
// SerializerGenerator
// **************************************************************************
abstract class TodoSerializer {
static Todo fromMap(Map map) {
if (map['is_complete'] == null) {
throw FormatException("Missing required field 'is_complete' on Todo.");
}
const TodoSerializer todoSerializer = TodoSerializer();
class TodoEncoder extends Converter<Todo, Map> {
const TodoEncoder();
@override
Map convert(Todo model) => TodoSerializer.toMap(model);
}
class TodoDecoder extends Converter<Map, Todo> {
const TodoDecoder();
@override
Todo convert(Map map) => TodoSerializer.fromMap(map);
}
class TodoSerializer extends Codec<Todo, Map> {
const TodoSerializer();
@override
TodoEncoder get encoder => const TodoEncoder();
@override
TodoDecoder get decoder => const TodoDecoder();
static Todo fromMap(Map map) {
return Todo(
id: map['id'] as String?,
isComplete: map['is_complete'] as bool? ?? false,
text: map['text'] as String?,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime?)
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime?)
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
: null,
isComplete: map['is_complete'] as bool? ?? false,
text: map['text'] as String?);
}
static Map<String, dynamic> toMap(_Todo model) {
if (model.isComplete == null) {
throw FormatException("Missing required field 'is_complete' on Todo.");
static Map<String, dynamic> toMap(_Todo? model) {
if (model == null) {
throw FormatException("Required field [model] cannot be null");
}
return {
'id': model.id,
'is_complete': model.isComplete,
'text': model.text,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
'updated_at': model.updatedAt?.toIso8601String(),
'is_complete': model.isComplete,
'text': model.text
};
}
}
@ -251,19 +288,19 @@ abstract class TodoSerializer {
abstract class TodoFields {
static const List<String> allFields = <String>[
id,
isComplete,
text,
createdAt,
updatedAt
updatedAt,
isComplete,
text
];
static const String id = 'id';
static const String isComplete = 'is_complete';
static const String text = 'text';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
static const String isComplete = 'is_complete';
static const String text = 'text';
}

View file

@ -1,156 +1,2 @@
import 'dart:async';
import 'package:angel3_orm/angel3_orm.dart';
import 'package:logging/logging.dart';
import 'package:mysql1/mysql1.dart';
class MySqlExecutor extends QueryExecutor {
/// An optional [Logger] to write to.
final Logger? logger;
final MySqlConnection _connection;
MySqlExecutor(this._connection, {this.logger});
final Dialect _dialect = const MySQLDialect();
@override
Dialect get dialect => _dialect;
Future<void> close() {
return _connection.close();
/*
if (_connection is MySqlConnection) {
return (_connection as MySqlConnection).close();
} else {
return Future.value();
}
*/
}
/*
Future<Transaction> _startTransaction() {
if (_connection is Transaction) {
return Future.value(_connection as Transaction?);
} else if (_connection is MySqlConnection) {
return (_connection as MySqlConnection).begin();
} else {
throw StateError('Connection must be transaction or connection');
}
}
@override
Future<List<List>> query(
String tableName, String query, Map<String, dynamic> substitutionValues,
[List<String> returningFields = const []]) {
// Change @id -> ?
for (var name in substitutionValues.keys) {
query = query.replaceAll('@$name', '?');
}
logger?.fine('Query: $query');
logger?.fine('Values: $substitutionValues');
if (returningFields.isNotEmpty != true) {
return _connection!
.prepared(query, substitutionValues.values)
.then((results) => results.map((r) => r.toList()).toList());
} else {
return Future(() async {
var tx = await _startTransaction();
try {
var writeResults =
await tx.prepared(query, substitutionValues.values);
var fieldSet = returningFields.map((s) => '`$s`').join(',');
var fetchSql = 'select $fieldSet from $tableName where id = ?;';
logger?.fine(fetchSql);
var readResults =
await tx.prepared(fetchSql, [writeResults.insertId]);
var mapped = readResults.map((r) => r.toList()).toList();
await tx.commit();
return mapped;
} catch (_) {
await tx.rollback();
rethrow;
}
});
}
}
*/
@override
Future<List<List>> query(
String tableName, String query, Map<String, dynamic> substitutionValues,
{String returningQuery = '',
List<String> returningFields = const []}) async {
// Change @id -> ?
for (var name in substitutionValues.keys) {
query = query.replaceAll('@$name', '?');
}
var params = substitutionValues.values.toList();
//logger?.warning('Query: $query');
//logger?.warning('Values: $params');
//logger?.warning('Returning Query: $returningQuery');
if (returningQuery.isNotEmpty) {
// Handle insert, update and delete
// Retrieve back the inserted record
if (query.startsWith("INSERT")) {
var result = await _connection.query(query, params);
query = returningQuery;
//logger?.warning('Result.insertId: ${result.insertId}');
// Has primary key
//if (result.insertId != 0) {
if (returningQuery.endsWith('.id=?')) {
params = [result.insertId];
}
} else if (query.startsWith("UPDATE")) {
await _connection.query(query, params);
query = returningQuery;
params = [];
}
}
// Handle select
return _connection.query(query, params).then((results) {
return results.map((r) => r.toList()).toList();
});
}
@override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
return f(this);
/*
if (_connection is! MySqlConnection) {
return await f(this);
}
await _connection.transaction((context) async {
var executor = MySqlExecutor(context, logger: logger);
});
*/
}
/*
@override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
if (_connection is Transaction) {
return await f(this);
}
Transaction? tx;
try {
tx = await _startTransaction();
var executor = MySqlExecutor(tx, logger: logger);
var result = await f(executor);
await tx.commit();
return result;
} catch (_) {
await tx?.rollback();
rethrow;
}
}
*/
}
export 'src/orm_mariadb.dart';
export 'src/orm_mysql.dart';

View file

@ -0,0 +1,156 @@
import 'dart:async';
import 'package:angel3_orm/angel3_orm.dart';
import 'package:logging/logging.dart';
import 'package:mysql1/mysql1.dart';
class MariaDbExecutor extends QueryExecutor {
/// An optional [Logger] to write to.
final Logger? logger;
final MySqlConnection _connection;
MariaDbExecutor(this._connection, {this.logger});
final Dialect _dialect = const MySQLDialect();
@override
Dialect get dialect => _dialect;
Future<void> close() {
return _connection.close();
/*
if (_connection is MySqlConnection) {
return (_connection as MySqlConnection).close();
} else {
return Future.value();
}
*/
}
/*
Future<Transaction> _startTransaction() {
if (_connection is Transaction) {
return Future.value(_connection as Transaction?);
} else if (_connection is MySqlConnection) {
return (_connection as MySqlConnection).begin();
} else {
throw StateError('Connection must be transaction or connection');
}
}
@override
Future<List<List>> query(
String tableName, String query, Map<String, dynamic> substitutionValues,
[List<String> returningFields = const []]) {
// Change @id -> ?
for (var name in substitutionValues.keys) {
query = query.replaceAll('@$name', '?');
}
logger?.fine('Query: $query');
logger?.fine('Values: $substitutionValues');
if (returningFields.isNotEmpty != true) {
return _connection!
.prepared(query, substitutionValues.values)
.then((results) => results.map((r) => r.toList()).toList());
} else {
return Future(() async {
var tx = await _startTransaction();
try {
var writeResults =
await tx.prepared(query, substitutionValues.values);
var fieldSet = returningFields.map((s) => '`$s`').join(',');
var fetchSql = 'select $fieldSet from $tableName where id = ?;';
logger?.fine(fetchSql);
var readResults =
await tx.prepared(fetchSql, [writeResults.insertId]);
var mapped = readResults.map((r) => r.toList()).toList();
await tx.commit();
return mapped;
} catch (_) {
await tx.rollback();
rethrow;
}
});
}
}
*/
@override
Future<List<List>> query(
String tableName, String query, Map<String, dynamic> substitutionValues,
{String returningQuery = '',
List<String> returningFields = const []}) async {
// Change @id -> ?
for (var name in substitutionValues.keys) {
query = query.replaceAll('@$name', '?');
}
var params = substitutionValues.values.toList();
//logger?.warning('Query: $query');
//logger?.warning('Values: $params');
//logger?.warning('Returning Query: $returningQuery');
if (returningQuery.isNotEmpty) {
// Handle insert, update and delete
// Retrieve back the inserted record
if (query.startsWith("INSERT")) {
var result = await _connection.query(query, params);
query = returningQuery;
//logger?.warning('Result.insertId: ${result.insertId}');
// Has primary key
//if (result.insertId != 0) {
if (returningQuery.endsWith('.id=?')) {
params = [result.insertId];
}
} else if (query.startsWith("UPDATE")) {
await _connection.query(query, params);
query = returningQuery;
params = [];
}
}
// Handle select
return _connection.query(query, params).then((results) {
return results.map((r) => r.toList()).toList();
});
}
@override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
return f(this);
/*
if (_connection is! MySqlConnection) {
return await f(this);
}
await _connection.transaction((context) async {
var executor = MySqlExecutor(context, logger: logger);
});
*/
}
/*
@override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
if (_connection is Transaction) {
return await f(this);
}
Transaction? tx;
try {
tx = await _startTransaction();
var executor = MySqlExecutor(tx, logger: logger);
var result = await f(executor);
await tx.commit();
return result;
} catch (_) {
await tx?.rollback();
rethrow;
}
}
*/
}

View file

@ -0,0 +1,172 @@
import 'dart:async';
import 'package:angel3_orm/angel3_orm.dart';
import 'package:logging/logging.dart';
import 'package:mysql_client/mysql_client.dart';
class MySqlExecutor extends QueryExecutor {
/// An optional [Logger] to write to.
final Logger? logger;
final MySQLConnection _connection;
MySqlExecutor(this._connection, {this.logger});
final Dialect _dialect = const MySQLDialect();
@override
Dialect get dialect => _dialect;
Future<void> close() {
return _connection.close();
/*
if (_connection is MySqlConnection) {
return (_connection as MySqlConnection).close();
} else {
return Future.value();
}
*/
}
/*
Future<Transaction> _startTransaction() {
if (_connection is Transaction) {
return Future.value(_connection as Transaction?);
} else if (_connection is MySqlConnection) {
return (_connection as MySqlConnection).begin();
} else {
throw StateError('Connection must be transaction or connection');
}
}
@override
Future<List<List>> query(
String tableName, String query, Map<String, dynamic> substitutionValues,
[List<String> returningFields = const []]) {
// Change @id -> ?
for (var name in substitutionValues.keys) {
query = query.replaceAll('@$name', '?');
}
logger?.fine('Query: $query');
logger?.fine('Values: $substitutionValues');
if (returningFields.isNotEmpty != true) {
return _connection!
.prepared(query, substitutionValues.values)
.then((results) => results.map((r) => r.toList()).toList());
} else {
return Future(() async {
var tx = await _startTransaction();
try {
var writeResults =
await tx.prepared(query, substitutionValues.values);
var fieldSet = returningFields.map((s) => '`$s`').join(',');
var fetchSql = 'select $fieldSet from $tableName where id = ?;';
logger?.fine(fetchSql);
var readResults =
await tx.prepared(fetchSql, [writeResults.insertId]);
var mapped = readResults.map((r) => r.toList()).toList();
await tx.commit();
return mapped;
} catch (_) {
await tx.rollback();
rethrow;
}
});
}
}
*/
@override
Future<List<List>> query(
String tableName, String query, Map<String, dynamic> substitutionValues,
{String returningQuery = '',
List<String> returningFields = const []}) async {
// Change @id -> ?
for (var name in substitutionValues.keys) {
query = query.replaceAll('@$name', ':$name');
}
//var params = substitutionValues.values.toList();
var params = [];
logger?.warning('Query: $query');
logger?.warning('Values: $substitutionValues');
//logger?.warning('Returning Query: $returningQuery');
if (returningQuery.isNotEmpty) {
// Handle insert, update and delete
// Retrieve back the inserted record
if (query.startsWith("INSERT")) {
var result = await _connection.execute(query, substitutionValues);
logger?.warning(result.lastInsertID);
query = returningQuery;
//logger?.warning('Result.insertId: ${result.insertId}');
// Has primary key
//if (result.insertId != 0) {
if (returningQuery.endsWith('.id=?')) {
query = query.replaceAll("?", ":id");
//params = [result.lastInsertID];
substitutionValues.clear();
substitutionValues['id'] = result.lastInsertID;
}
} else if (query.startsWith("UPDATE")) {
await _connection.execute(query, substitutionValues);
query = returningQuery;
params = [];
}
}
logger?.warning('Query 2: $query');
logger?.warning('Values 2: $substitutionValues');
// Handle select
return _connection.execute(query, substitutionValues).then((results) {
logger?.warning("SELECT");
//for (var element in results.cols) {
// print(
// '${element.name} ${element.type.toString()} ${element.runtimeType.toString()}');
//}
return results.rows.map((r) => r.typedAssoc().values.toList()).toList();
});
}
@override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
logger?.warning("Transaction");
return f(this);
/*
if (_connection is! MySqlConnection) {
return await f(this);
}
await _connection.transaction((context) async {
var executor = MySqlExecutor(context, logger: logger);
});
*/
}
/*
@override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
if (_connection is Transaction) {
return await f(this);
}
Transaction? tx;
try {
tx = await _startTransaction();
var executor = MySqlExecutor(tx, logger: logger);
var result = await f(executor);
await tx.commit();
return result;
} catch (_) {
await tx?.rollback();
rethrow;
}
}
*/
}

View file

@ -4,19 +4,24 @@ description: MySQL support for Angel3 ORM. Includes functionality for querying a
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_mysql
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_orm: ^6.0.0
logging: ^1.0.0
mysql1: ^0.19.0
mysql_client: ^0.0.11
optional: ^6.0.0
dev_dependencies:
angel3_orm_generator: ^6.0.0
angel3_orm_test: ^6.0.0
build_runner: ^2.0.1
test: ^1.17.0
lints: ^1.0.0
dependency_overrides:
angel3_serialize:
path: ../../serialize/angel_serialize
angel3_serialize_generator:
path: ../../serialize/angel_serialize_generator
angel3_model:
path: ../../model
angel3_orm_test:
@ -25,5 +30,5 @@ dependency_overrides:
path: ../angel_orm
angel3_migration:
path: ../angel_migration
angel3_orm_generator:
path: ../angel_orm_generator

View file

@ -4,6 +4,7 @@ import 'package:angel3_orm/angel3_orm.dart';
import 'package:angel3_orm_mysql/angel3_orm_mysql.dart';
import 'package:logging/logging.dart';
import 'package:mysql1/mysql1.dart';
import 'package:mysql_client/mysql_client.dart';
FutureOr<QueryExecutor> Function() my(Iterable<String> schemas) {
return () => connectToMySql(schemas);
@ -12,14 +13,16 @@ FutureOr<QueryExecutor> Function() my(Iterable<String> schemas) {
Future<void> closeMy(QueryExecutor executor) =>
(executor as MySqlExecutor).close();
Future<MySqlExecutor> connectToMySql(Iterable<String> schemas) async {
// Executor for MariaDB 10.2.x
Future<MariaDbExecutor> connectToMariaDb(Iterable<String> schemas) async {
var settings = ConnectionSettings(
host: 'localhost',
port: 3306,
db: 'orm_test',
host: "localhost",
user: Platform.environment['MYSQL_USERNAME'] ?? 'Test',
password: Platform.environment['MYSQL_PASSWORD'] ?? 'Test123*',
timeout: Duration(minutes: 10));
user: 'Test',
password: 'Test123*');
var connection = await MySqlConnection.connect(settings);
var logger = Logger('orm_mysql');
for (var s in schemas) {
@ -29,10 +32,40 @@ Future<MySqlExecutor> connectToMySql(Iterable<String> schemas) async {
for (var q in queries) {
//print("Table: [$q]");
if (q.trim().isNotEmpty) {
//await connection.execute(q);
await connection.query(q);
}
}
}
return MariaDbExecutor(connection, logger: logger);
}
// Executor for MySQL 8.x.x
Future<MySqlExecutor> connectToMySql(Iterable<String> schemas) async {
var connection = await MySQLConnection.createConnection(
databaseName: 'orm_test',
port: 3306,
host: "localhost",
userName: Platform.environment['MYSQL_USERNAME'] ?? 'test',
password: Platform.environment['MYSQL_PASSWORD'] ?? 'Test123*',
);
await connection.connect();
var logger = Logger('orm_mysql');
for (var s in schemas) {
// MySQL driver does not support multiple sql queries
var data = await File('test/migrations/$s.sql').readAsString();
var queries = data.split(";");
for (var q in queries) {
//print("Table: [$q]");
if (q.trim().isNotEmpty) {
await connection.execute(q);
}
}
}
return MySqlExecutor(connection, logger: logger);
}

View file

@ -2,15 +2,15 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.0.0
* No release. Skipped
* Skipped release
## 3.3.0

View file

@ -4,7 +4,7 @@ description: PostgreSQL support for Angel3 ORM. Includes functionality for query
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_postgres
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_orm: ^6.0.0
logging: ^1.0.1

View file

@ -2,19 +2,19 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.0.0
* No release. Skipped
* Skipped release
## 3.0.0
* No release. Skipped
* Skipped release
## 2.0.1

View file

@ -4,7 +4,7 @@ description: Service implementation that wraps over Angel3 ORM Query classes.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_service
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^6.0.0
angel3_orm: ^6.0.0

View file

@ -2,15 +2,15 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.0.0
* No release. Skipped
* Skipped release
## 3.1.2

View file

@ -97,7 +97,7 @@ class CarQuery extends Query<Car, CarQueryWhere> {
description:
fields.contains('description') ? (row[4] as String?) : null,
familyFriendly:
fields.contains('family_friendly') ? (row[5] as bool?) : null,
fields.contains('family_friendly') ? mapToBool(row[5]) : null,
recalledAt:
fields.contains('recalled_at') ? (row[6] as DateTime?) : null);
return Optional.of(model);

View file

@ -100,7 +100,7 @@ class PersonOrderQuery extends Query<PersonOrder, PersonOrderQueryWhere> {
price: fields.contains('price')
? double.tryParse(row[5].toString())
: null,
deleted: fields.contains('deleted') ? (row[6] as bool?) : null);
deleted: fields.contains('deleted') ? mapToBool(row[6]) : null);
return Optional.of(model);
}
@ -264,7 +264,7 @@ class OrderWithPersonInfoQuery
price: fields.contains('price')
? double.tryParse(row[4].toString())
: null,
deleted: fields.contains('deleted') ? (row[5] as bool?) : null,
deleted: fields.contains('deleted') ? mapToBool(row[5]) : null,
personName: fields.contains('person_name') ? (row[6] as String?) : null,
personAge: fields.contains('person_age') ? (row[7] as int?) : null);
return Optional.of(model);

View file

@ -173,9 +173,9 @@ void standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
});
test('insert', () async {
var recalledAt = DateTime.now();
var recalledAt = DateTime.now().toUtc();
var query = CarQuery();
var now = DateTime.now();
var now = DateTime.now().toUtc();
query.values
..make = 'Honda'
..description = 'Hello'
@ -198,7 +198,7 @@ void standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
});
test('insert car', () async {
var recalledAt = DateTime.now();
var recalledAt = DateTime.now().toUtc();
var beetle = Car(
make: 'Beetle',
description: 'Herbie',

View file

@ -4,7 +4,7 @@ description: Common tests for Angel3 ORM. Reference implmentation of the generat
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_test
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_migration: ^6.0.0
angel3_model: ^6.0.0

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
export POSTGRES_USERNAME="angel_orm"
export POSTGRES_PASSWORD="angel_orm"
set -ex
function angel_orm_test () {
cd $1;
pub get;
pub run test;
cd ..
}
cd angel_orm_generator;
pub get;
echo 1 | pub run build_runner build --delete-conflicting-outputs;
cd ..;
angel_orm_test angel_orm_postgres
angel_orm_test angel_orm_service

View file

@ -1 +0,0 @@
language: dart

View file

@ -1,5 +1,17 @@
# Change Log
## 6.0.0
* Updated to SDK 2.16.x
## 5.0.0
* Skipped release
## 4.0.0
* Skipped release
## 3.1.0
* Updated linter to `package:lints`

View file

@ -1,14 +1,14 @@
name: angel3_paginate
version: 3.1.0
version: 6.0.0
description: Platform-agnostic pagination library, with custom support for the Angel3 framework.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/paginate
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_framework: ^4.2.0
angel3_framework: ^6.0.0
dev_dependencies:
angel3_test: ^4.1.0
angel3_test: ^6.0.0
logging: ^1.0.1
test: ^1.17.8
lints: ^1.0.0

View file

@ -2,15 +2,15 @@
## 6.0.0
* Updated to min SDK 2.15.x
* Updated to SDK 2.16.x
## 5.0.0
* No release. Skipped
* Skipped release
## 4.0.0
* No release. Skipped
* Skipped release
## 3.1.2

View file

@ -4,7 +4,7 @@ description: Helpers for concurrency, message-passing, rotating loggers, and oth
homepage: https://angel3-framework.web.app
repository: https://github.com/dukefirehawk/angel/tree/master/packages/production
environment:
sdk: '>=2.15.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
dependencies:
angel3_container: ^6.0.0
angel3_framework: ^6.0.0

View file

@ -1 +0,0 @@
language: dart

Some files were not shown because too many files have changed in this diff Show more