angel_orm_generator 2.0.5

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]
46
Health:
Code health derived from static analysis. [more]
87
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: other

Primary library: package:angel_orm_generator/angel_orm_generator.dart with components: io, build, mirrors.

Health suggestions

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

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

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

line 262 col 13: DO use curly braces for all flow control structures.

line 271 col 9: DO use curly braces for all flow control structures.

line 275 col 9: DO use curly braces for all flow control structures.

line 284 col 5: DO use curly braces for all flow control structures.

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

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

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.

line 87 col 17: DO use curly braces for all flow control structures.

line 115 col 17: DO use curly braces for all flow control structures.

line 122 col 23: DO use curly braces for all flow control structures.

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

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

line 181 col 17: DO use curly braces for all flow control structures.

line 183 col 17: DO use curly braces for all flow control structures.

line 197 col 17: DO use curly braces for all flow control structures.

line 348 col 20: Dead code.

line 406 col 11: Dead code.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
analyzer >=0.27.1 <2.0.0 0.37.0
angel_model ^1.0.0 1.0.3
angel_orm ^2.0.0-dev 2.0.1
angel_serialize ^2.0.0 2.2.3+2
angel_serialize_generator ^2.0.0 2.5.0
build >=0.12.0 <2.0.0 1.1.5
build_config >=0.3.0 <0.5.0 0.4.1
code_builder ^3.0.0 3.2.0
dart_style ^1.0.0 1.2.9
inflection2 ^0.4.2 0.4.2
meta ^1.0.0 1.1.7
path ^1.0.0 1.6.2
recase ^2.0.0 2.0.1
source_gen ^0.9.0 0.9.4+3
Transitive dependencies
args 1.5.2
async 2.3.0
built_collection 4.2.2
built_value 6.7.0
charcode 1.1.2
checked_yaml 1.0.1
code_buffer 1.0.1
convert 2.1.1
crypto 2.0.6
csslib 0.16.1
fixnum 0.10.9
front_end 0.1.20
glob 1.1.7
html 0.14.0+2
intl 0.15.8
json_annotation 2.4.0
kernel 0.3.20
logging 0.11.3+2
matcher 0.12.5
package_config 1.0.5
pedantic 1.8.0+1
pub_semver 1.4.2
pubspec_parse 0.1.4
quiver 2.0.3
quiver_hashcode 2.0.0
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+12
yaml 2.1.16
Dev dependencies
angel_framework ^2.0.0-alpha
angel_migration
build_runner ^1.0.0
collection ^1.0.0 1.14.11
postgres ^1.0.0
test ^1.0.0

Admin