angel_orm_generator 2.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 64

angel_orm_generator #

Source code generators for Angel's ORM. This package can generate:

  • A strongly-typed ORM
  • SQL migration scripts

For documentation about the ORM, head to the main project repo: https://github.com/angel-dart/orm

2.0.5 #

  • Remove ShimFieldImpl check, which broke relations.
  • Fix bug where primary key type would not be emitted in migrations.
  • Fix ManyToMany ignoring primary key types.

2.0.4 #

  • Fix reviveColumn and element finding to properly detect all annotations now.

2.0.3 #

  • Remove targets in build.yaml.

2.0.2 #

  • Change build_config range to ">=0.3.0 <0.5.0".

2.0.1 #

  • Gracefully handle null in enum fields.
  • Add take to wherever skip is used.

2.0.0+2 #

  • Widen analyzer dependency range.

2.0.0+1 #

  • Restore build.yaml, which at some point, got deleted.

2.0.0 #

  • parse -> tryParse where used.

2.0.0-dev.7 #

  • Handle @ManyToMany.
  • Handle cases where the class is not a Model.
    • Stop assuming things have id, etc.
  • Resolve a bug where the indexType of @Column annotations. would not be found.
  • Add cascade: true to drops for hasOne/hasMany/ManyToMany migrations.
  • Support enum default values in migrations.

2.0.0-dev.6 #

  • Fix bug where an extra field would be inserted into joins and botch the result.
  • Narrow analyzer dependency.

2.0.0-dev.5 #

  • Implement cast-based double support.
  • Finish ListSqlExpressionBuilder.

2.0.0-dev.4 #

  • List generation support.

2.0.0-dev.3 #

  • Add JSON/JSONB support for Maps.

2.0.0-dev.2 #

  • Changes to work with package:angel_orm@2.0.0-dev.15.

2.0.0-dev.1 #

  • Generate migration files.

2.0.0-dev #

  • Dart 2 updates, and more.

1.0.0-alpha+6 #

  • DateTime is now CAST on insertion and update operations.

1.0.0-alpha+3 #

Implemented @hasOne, with tests. Still missing @hasMany. belongsToMany will likely be scrapped.

1.0.0-alpha+2 #

  • Added support for belongsTo relationships. Still missing hasOne, hasMany, belongsToMany.

1.0.0-alpha+1 #

  • Closed #12. insertX and updateX now use rc.camelCase, instead of rc.snakeCase.
  • Closed #13. Added limit and offset properties to XQuery.
  • Closed #14. Refined the or method (it now takes an XQueryWhere), and removed and and not.
  • Closed #16. Added sortAscending and sortDescending to XQuery.
  • Closed #17. delete now uses toSql from XQuery.
  • Closed #18. XQuery now supports union and unionAll.

example/main.dart

import 'dart:async';
import 'package:angel_migration/angel_migration.dart';
import 'package:angel_model/angel_model.dart';
import 'package:angel_orm/angel_orm.dart';
import 'package:angel_orm/src/query.dart';
import 'package:angel_serialize/angel_serialize.dart';
part 'main.g.dart';

main() async {
  var query = new EmployeeQuery()
    ..where.firstName.equals('Rich')
    ..where.lastName.equals('Person')
    ..orWhere((w) => w.salary.greaterThanOrEqualTo(75000))
    ..join('companies', 'company_id', 'id');

  var richPerson = await query.getOne(new _FakeExecutor());
  print(richPerson.toJson());
}

class _FakeExecutor extends QueryExecutor {
  const _FakeExecutor();

  @override
  Future<List<List>> query(
      String tableName, String query, Map<String, dynamic> substitutionValues,
      [returningFields]) async {
    var now = new DateTime.now();
    print(
        '_FakeExecutor received query: $query and values: $substitutionValues');
    return [
      [1, 'Rich', 'Person', 100000.0, now, now]
    ];
  }

  @override
  Future<T> transaction<T>(FutureOr<T> Function() f) {
    throw new UnsupportedError('Transactions are not supported.');
  }
}

@orm
@serializable
abstract class _Employee extends Model {
  String get firstName;

  String get lastName;

  @Column(indexType: IndexType.unique)
  String uniqueId;

  double get salary;
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  angel_orm_generator: ^2.0.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:angel_orm_generator/angel_orm_generator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
47
Health:
Code health derived from static analysis. [more]
75
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
89
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Jul 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Analysis suggestions

Package not compatible with SDK flutter

Because it is not compatible with any of the supported runtimes: flutter-native, flutter-web

Package not compatible with runtime flutter-native on android

Because of the import of dart:mirrors via the import chain package:angel_orm_generator/angel_orm_generator.dartpackage:angel_orm_generator/src/readers.dartpackage:angel_orm_generator/src/orm_build_context.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-native on ios

Because of the import of dart:mirrors via the import chain package:angel_orm_generator/angel_orm_generator.dartpackage:angel_orm_generator/src/readers.dartpackage:angel_orm_generator/src/orm_build_context.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-native on linux

Because of the import of dart:mirrors via the import chain package:angel_orm_generator/angel_orm_generator.dartpackage:angel_orm_generator/src/readers.dartpackage:angel_orm_generator/src/orm_build_context.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-native on macos

Because of the import of dart:mirrors via the import chain package:angel_orm_generator/angel_orm_generator.dartpackage:angel_orm_generator/src/readers.dartpackage:angel_orm_generator/src/orm_build_context.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-native on windows

Because of the import of dart:mirrors via the import chain package:angel_orm_generator/angel_orm_generator.dartpackage:angel_orm_generator/src/readers.dartpackage:angel_orm_generator/src/orm_build_context.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:angel_orm_generator/angel_orm_generator.dartpackage:angel_orm_generator/src/readers.dartpackage:angel_orm_generator/src/orm_build_context.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/utils.dartpackage:build/build.dartpackage:build/src/generate/run_post_process_builder.dartpackage:build/src/builder/post_process_builder.dartpackage:build/src/builder/builder.dartpackage:build/src/builder/build_step.dartpackage:build/src/asset/reader.dartpackage:glob/glob.dartpackage:glob/src/list_tree.dartpackage:glob/src/io.dartpackage:glob/src/io_export.dartdart:io

Package not compatible with runtime native-aot

Because of the import of dart:mirrors via the import chain package:angel_orm_generator/angel_orm_generator.dartpackage:angel_orm_generator/src/readers.dartpackage:angel_orm_generator/src/orm_build_context.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime web

Because of the import of dart:io via the import chain package:angel_orm_generator/angel_orm_generator.dartpackage:angel_orm_generator/src/readers.dartpackage:angel_orm_generator/src/orm_build_context.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/utils.dartpackage:build/build.dartpackage:build/src/generate/run_post_process_builder.dartpackage:build/src/builder/post_process_builder.dartpackage:build/src/builder/builder.dartpackage:build/src/builder/build_step.dartpackage:build/src/asset/reader.dartpackage:glob/glob.dartpackage:glob/src/list_tree.dartpackage:glob/src/io.dartpackage:glob/src/io_export.dartdart:io

Health suggestions

Fix lib/src/orm_generator.dart. (-25 points)

Analysis of lib/src/orm_generator.dart reported 78 hints, including:

line 20 col 10: Unnecessary new keyword.

line 21 col 5: Unnecessary new keyword.

line 27 col 10: Unnecessary new keyword.

line 45 col 25: Unnecessary new keyword.

line 52 col 12: Unnecessary new keyword.

Fix lib/src/orm_build_context.dart. (-16.09 points)

Analysis of lib/src/orm_build_context.dart reported 35 hints, including:

line 28 col 64: 'type' is deprecated and shouldn't be used.

line 46 col 33: Unnecessary new keyword.

line 69 col 22: Use = to separate a named parameter from its default value.

line 91 col 13: Unnecessary new keyword.

line 96 col 23: Unnecessary new keyword.

Fix lib/src/migration_generator.dart. (-13.96 points)

Analysis of lib/src/migration_generator.dart reported 30 hints, including:

line 14 col 10: Unnecessary new keyword.

line 15 col 5: Unnecessary new keyword.

line 21 col 41: Unnecessary new keyword.

line 29 col 52: Use = to separate a named parameter from its default value.

line 35 col 7: DO use curly braces for all flow control structures.

Fix lib/src/readers.dart. (-0.50 points)

Analysis of lib/src/readers.dart reported 1 hint:

line 8 col 39: Avoid const keyword.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (recase).

Package is getting outdated. (-1.10 points)

The package was last published 52 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
analyzer >=0.27.1 <2.0.0 0.39.12
angel_model ^1.0.0 1.0.3
angel_orm ^2.0.0-dev 2.0.2 2.1.0-beta.3
angel_serialize ^2.0.0 2.2.3+3
angel_serialize_generator ^2.0.0 2.5.0
build >=0.12.0 <2.0.0 1.3.0
build_config >=0.3.0 <0.5.0 0.4.2
code_builder ^3.0.0 3.3.0
dart_style ^1.0.0 1.3.6
inflection2 ^0.4.2 0.4.3
meta ^1.0.0 1.2.1
path ^1.0.0 1.7.0
recase ^2.0.0 2.0.1 3.0.0
source_gen ^0.9.0 0.9.5
Transitive dependencies
_fe_analyzer_shared 5.0.0
args 1.6.0
async 2.4.2
built_collection 4.3.2
built_value 7.1.0
charcode 1.1.3
checked_yaml 1.0.2
code_buffer 1.0.1
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
fixnum 0.10.11
glob 1.2.0
html 0.14.0+3
intl 0.15.8 0.16.1
js 0.6.2
json_annotation 3.0.1
logging 0.11.4
matcher 0.12.8
node_interop 1.1.1
node_io 1.1.1
package_config 1.9.3
pedantic 1.9.1
pub_semver 1.4.4
pubspec_parse 0.1.5
quiver 2.1.3
quiver_hashcode 2.0.0
source_span 1.7.0
stack_trace 1.9.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0
watcher 0.9.7+15
yaml 2.2.1
Dev dependencies
angel_framework ^2.0.0-alpha
angel_migration
build_runner ^1.0.0
collection ^1.0.0 1.14.13
postgres ^1.0.0
test ^1.0.0