5

On the system: Dart VM version: 2.9.0-14.0.dev.flutter-2b917f5b6a (be) (Wed Jun 10 15:46:47 2020 +0000) on "windows_x64"

It is OK when run "aqueduct db generate" to create 00000001_initial.migration.dart But, after edit models and rerun "aqueduct db generate", I get the message as below. After delete 00000001_initial.migration.dart and rerun, it is OK.

The message:

-- Aqueduct CLI Version: 3.3.0+1 -- Aqueduct project version: 3.2.0 *** Uncaught error Bad state: NoSuchMethodError: The getter 'length' was called on null. Receiver: null Tried calling: length **** Stacktrace

  • #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
  • #1 _ClassMirror.newInstance (dart:mirrors-patch/mirrors_impl.dart:653:44)
  • #2 Executable.instanceOf (data:application/dart:14:813)
  • #3 SchemaBuilderExecutable.execute (data:application/dart:13:873)
  • #4 main (data:application/dart:9:35)
  • #5 _startIsolate. (dart:isolate-patch/isolate_patch.dart:297:32)
  • #6 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Please help me!

Tony
  • 51
  • 1
  • 2

4 Answers4

3

It's a bug and it's still there. Happens when there is a previous migration file.

Just erase migrations/00000001_initial.migration.dart and then aqueduct db generate will work as expected.

Tested on Aqueduct 4.0.0-b1

p.s. I know it's the same solution given in the question but I was having the same problem and the solution wasn't clear at first.

J. Pelaez
  • 86
  • 4
  • 1
    Removing the first migration might be a valid workaround when you haven't run any migration yet, but for any system already in production or even where local databases have already been upgraded to the first migration, this solution will not work. The replacement migration would create tables that already exist etc. – Bouke Versteegh Dec 24 '20 at 10:45
  • Thanks! And it's still happening 10 months later... – MappaM Feb 19 '21 at 20:27
2

They actually fixed it

It's just not on pub.dev yet.

lukas83
  • 441
  • 5
  • 9
0

You can try to downgrade the Dart version.

brew tap dart-lang/dart

brew uninstall dart

brew install dart@2.8

It helped me.

UPDATED:

Here is the content of my pubspec.yaml file:

name: mysecurename
description: mysecuredescription
version: 0.1.0

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  aqueduct: ^4.0.0-b1
  analyzer: '>=0.32.0 <0.41.0'
  runtime: ^1.0.0-5
  http: ^0.12.0+4
  mime: ^0.9.6+3

dev_dependencies:
  test: ^1.0.0
  aqueduct_test: ^2.0.0-b1
Oleksandr Nahirniak
  • 1,357
  • 2
  • 9
  • 12
  • with Dart 2.8 `aqueduct db generate` will work, but then `aqueduct db update` fails with a `RangeError` even with `dependency_overrides: Postgres: 2.2.0` workaround suggested in various posts. Dart 2.7 is the only version that worked for me and without `dependency_overrides: Postgres: 2.2.0`. What is your setup with dart 2.8? – Vincenzo Jan 06 '21 at 10:59
  • Updated the answer with the content of my ```pubspec.yaml``` file – Oleksandr Nahirniak Jan 11 '21 at 12:24
  • Also, after fixing an issue with ```aqueduct db generate```. I've started to receive issues with ```aqueduct db upgrade``` with SSL connection to remote PostgreSQL. As a workaround I upgraded(```aqueduct db upgrade```) the local PostgreSQL, take SQL changes from stdout and apply them directly to a remote machine. – Oleksandr Nahirniak Jan 11 '21 at 12:31
0

With the isolate_executor package (for aqueduct 3.2.0, dart 2.10.0 on Windows 10), I just added the default value "const {}" for namedArguments of "instanceOf" function definition of class Executable in lib\src\isolate_executor.dart as follows: (origin)

U instanceOf<U> (String typeName, {List positionalArguments: const [], Map <Symbol, dynamic> namedArguments, Symbol constructorName}) {...}

(modified):

U instanceOf<U> (String typeName, {List positionalArguments: const [], Map <Symbol, dynamic> namedArguments: const {}, Symbol constructorName}) {...}

It worked fine, including dart 2.10.0. I don't know why, because in the function definition of dart already has this default value declaration.

InstanceMirror newInstance (
       Symbol constructorName, List <dynamic> positionalArguments,
       [Map <Symbol, dynamic> namedArguments = const <Symbol, dynamic> {}]);

Please check and correct me if I am wrong.

Tony
  • 51
  • 1
  • 2