Fixed anlyzer warnings

This commit is contained in:
Thomas Hii 2024-06-24 07:54:16 +08:00
parent b39795b67b
commit d57dbae6f9
14 changed files with 33 additions and 38 deletions

View file

@ -1,5 +1,9 @@
# Change Log # Change Log
## 8.3.2
* Fixed analyzer warnings
## 8.3.1 ## 8.3.1
* Updated dependencies * Updated dependencies

View file

@ -219,7 +219,7 @@ Future<OrmBuildContext?> buildOrmContext(
} }
} on StackOverflowError { } on StackOverflowError {
throw UnsupportedError( throw UnsupportedError(
'There is an infinite cycle between ${clazz.name} and ${field.type.getDisplayString(withNullability: true)}. This triggered a stack overflow.'); 'There is an infinite cycle between ${clazz.name} and ${field.type.getDisplayString()}. This triggered a stack overflow.');
} }
} }
} }

View file

@ -745,7 +745,7 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
if (const TypeChecker.fromRuntime(int).isExactlyType(type) || if (const TypeChecker.fromRuntime(int).isExactlyType(type) ||
const TypeChecker.fromRuntime(double).isExactlyType(type) || const TypeChecker.fromRuntime(double).isExactlyType(type) ||
isSpecialId(ctx, field)) { isSpecialId(ctx, field)) {
var typeName = type.getDisplayString(withNullability: false); var typeName = type.getDisplayString();
if (isSpecialId(ctx, field)) { if (isSpecialId(ctx, field)) {
typeName = 'int'; typeName = 'int';
} }

View file

@ -1,5 +1,5 @@
name: angel3_orm_generator name: angel3_orm_generator
version: 8.3.1 version: 8.3.2
description: Code generators for Angel3 ORM. Generates query builder classes. description: Code generators for Angel3 ORM. Generates query builder classes.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_orm_generator repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_orm_generator

View file

@ -1,5 +1,9 @@
# Change Log # Change Log
## 8.2.2
* Fixed analyzer warnings
## 8.2.1 ## 8.2.1
* Updated dependencies * Updated dependencies

View file

@ -15,4 +15,6 @@ For documentation about the ORM, see [Developer Guide](https://angel3-docs.dukef
## Migration ## Migration
Posrgresql is upgraded from 2.x.x to 3.x.x in version 8.1.0. ### From version 7.x to 8.1.x
`postgres` has been upgraded from 2.x.x to 3.x.x since version 8.1.0. This is a breaking change as `postgres` 3.x.x has majorly changed its API. Therefore when upgrading to 8.1.0 and beyond, the PostgreSQL connection settings need to be migrated. The rest should remain the same. Please see the example for the new PostgreSQL connection settings.

View file

@ -105,14 +105,12 @@ class PostgreSqlExecutor extends QueryExecutor {
var conn = _session as Connection; var conn = _session as Connection;
return await conn.runTx((session) async { return await conn.runTx((TxSession session) async {
try { try {
//logger.fine('Entering transaction');
var exec = PostgreSqlExecutor(session, logger: logger); var exec = PostgreSqlExecutor(session, logger: logger);
return await f(exec); return await f(exec);
} catch (e) { } catch (e) {
session.rollback(); session.rollback();
//ctx.cancelTransaction(reason: e.toString());
logger.warning("The transation has failed due to ", e); logger.warning("The transation has failed due to ", e);
rethrow; rethrow;
} }

View file

@ -54,7 +54,7 @@ class PostgreSqlPoolExecutor extends QueryExecutor {
} }
}); });
return _pool.run<Result>((session) async { return _pool.run<Result>((Session session) async {
return await session.execute(Sql.named(query), parameters: param); return await session.execute(Sql.named(query), parameters: param);
}); });
} }

View file

@ -1,5 +1,5 @@
name: angel3_orm_postgres name: angel3_orm_postgres
version: 8.2.1 version: 8.2.2
description: PostgreSQL support for Angel3 ORM. Includes functionality for querying and transactions. description: PostgreSQL support for Angel3 ORM. Includes functionality for querying and transactions.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_orm_postgres repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_orm_postgres
@ -9,7 +9,7 @@ dependencies:
angel3_orm: ^8.2.0 angel3_orm: ^8.2.0
logging: ^1.2.0 logging: ^1.2.0
pool: ^1.5.0 pool: ^1.5.0
postgres: ^3.0.0 postgres: ^3.2.0
dev_dependencies: dev_dependencies:
belatuk_pretty_logging: ^6.1.0 belatuk_pretty_logging: ^6.1.0
angel3_orm_generator: ^8.2.0 angel3_orm_generator: ^8.2.0

View file

@ -8,7 +8,7 @@
## 8.2.1 ## 8.2.1
* Updated dependencies * Updated dependencies
* Updated `popstgres` to 3.0.0 * [BREAKING] Updated `postgres` to 3.2.0
## 8.2.0 ## 8.2.0

View file

@ -8,7 +8,7 @@ environment:
dependencies: dependencies:
angel3_framework: ^8.4.0 angel3_framework: ^8.4.0
angel3_orm: ^8.2.0 angel3_orm: ^8.2.0
postgres: ^3.0.0 postgres: ^3.2.0
optional: ^6.0.0 optional: ^6.0.0
dev_dependencies: dev_dependencies:
angel3_migration: ^8.2.0 angel3_migration: ^8.2.0

View file

@ -1,5 +1,9 @@
# Change Log # Change Log
## 8.2.1
* Fixed analyzer warnings
## 8.2.0 ## 8.2.0
* Require Dart >= 3.3 * Require Dart >= 3.3

View file

@ -1,5 +1,4 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:angel3_orm/angel3_orm.dart'; import 'package:angel3_orm/angel3_orm.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'models/user.dart'; import 'models/user.dart';
@ -12,6 +11,7 @@ void manyToManyTests(FutureOr<QueryExecutor> Function() createExecutor,
User? thosakwe; User? thosakwe;
close ??= (_) => null; close ??= (_) => null;
/*
Future<void> dumpQuery(String query) async { Future<void> dumpQuery(String query) async {
if (Platform.environment.containsKey('STFU')) return; if (Platform.environment.containsKey('STFU')) return;
print('\n'); print('\n');
@ -26,28 +26,11 @@ void manyToManyTests(FutureOr<QueryExecutor> Function() createExecutor,
} }
print('==================================================\n\n'); print('==================================================\n\n');
} }
*/
setUp(() async { setUp(() async {
executor = await createExecutor(); executor = await createExecutor();
// await dumpQuery("""
// WITH roles as
// (INSERT INTO roles (name)
// VALUES ('pyt')
// RETURNING roles.id, roles.name, roles.created_at, roles.updated_at)
// SELECT
// roles.id, roles.name, roles.created_at, roles.updated_at
// FROM roles
// LEFT JOIN
// (SELECT
// role_users.role_id, role_users.user_id,
// a0.id, a0.username, a0.password, a0.email, a0.created_at, a0.updated_at
// FROM role_users
// LEFT JOIN
// users a0 ON role_users.user_id=a0.id)
// a1 ON roles.id=a1.role_id
// """);
var canPubQuery = RoleQuery()..values.name = 'can_pub'; var canPubQuery = RoleQuery()..values.name = 'can_pub';
var canSubQuery = RoleQuery()..values.name = 'can_sub'; var canSubQuery = RoleQuery()..values.name = 'can_sub';
canPub = (await canPubQuery.insert(executor)).value; canPub = (await canPubQuery.insert(executor)).value;

View file

@ -1,22 +1,22 @@
name: angel3_orm_test name: angel3_orm_test
version: 8.2.0 version: 8.2.1
description: Common tests for Angel3 ORM. Reference implmentation of the generated ORM files. description: Common tests for Angel3 ORM. Reference implmentation of the generated ORM files.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_orm_test repository: https://github.com/dart-backend/angel/tree/master/packages/orm/angel_orm_test
environment: environment:
sdk: '>=3.3.0 <4.0.0' sdk: '>=3.3.0 <4.0.0'
dependencies: dependencies:
angel3_migration: ^8.0.0 angel3_migration: ^8.2.0
angel3_model: ^8.0.0 angel3_model: ^8.2.0
angel3_orm: ^8.0.0 angel3_orm: ^8.2.0
angel3_serialize: ^8.0.0 angel3_serialize: ^8.2.0
io: ^1.0.0 io: ^1.0.0
test: ^1.24.0 test: ^1.24.0
collection: ^1.17.0 collection: ^1.17.0
optional: ^6.1.0 optional: ^6.1.0
dev_dependencies: dev_dependencies:
angel3_orm_generator: ^8.0.0 angel3_orm_generator: ^8.3.0
angel3_framework: ^8.0.0 angel3_framework: ^8.4.0
build_runner: ^2.4.0 build_runner: ^2.4.0
lints: ^4.0.0 lints: ^4.0.0
#dependency_overrides: #dependency_overrides: