Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

transient property unsupported type #670

Open
moczix opened this issue May 9, 2019 · 4 comments
Open

transient property unsupported type #670

moczix opened this issue May 9, 2019 · 4 comments

Comments

@moczix
Copy link

moczix commented May 9, 2019

i got aqueduct 3.2.1 and tried to have many to many relation but got error, so i thought thats maybe its my fault. Then i copied code from documentation:

class Team extends ManagedObject<_Team> implements _Team {
  @Serialize(input: false, output: true)
  List<Player> players;
}
class _Team {
  @primaryKey
  int id;

  String name;

  ManagedSet<TeamPlayer> teamPlayers;
}

// This type is a join table
class TeamPlayer extends ManagedObject<_TeamPlayer> implements _TeamPlayer {}
class _TeamPlayer {
  @primaryKey
  int id;  

  @Relate(#teamPlayers)
  Team team;

  @Relate(#teamPlayers)
  Player player;
}

class Player extends ManagedObject<_Player> implements _Player {}
class _Player {
  @primaryKey
  int id;

  String name;

  ManagedSet<TeamPlayer> teamPlayers;
}

and got this error:

[SEVERE] aqueduct: Data Model Error: Property 'players' on 'Team' has an unsupported type. This can occur when the type cannot be stored in a database, or when a relationship does not have a valid inverse. If this property is supposed to be a relationship,  ensure the inverse property annotation is 'Relate(#players, ...)'. If this is not supposed to be a relationship property, its type must be one of: String, DateTime, bool, int, double, Document. Instance of 'Application<AqueductServerChannel>' #0      PropertyBuilder.validate (package:aqueduct/src/db/managed/builders/property_builder.dart:89:9)
#1      EntityBuilder.validate.<anonymous closure> (package:aqueduct/src/db/managed/builders/entity_builder.dart:106:33)
#2      List.forEach (dart:core-patch/growable_array.dart:278:8)
#3      EntityBuilder.validate (package:aqueduct/src/db/managed/builders/entity_builder.dart:106:16)
#4      DataModelBuilder._validate.<anonymous closure> (package:aqueduct/src/db/managed/builders/data_model_builder.dart:38:32)
#5      List.forEach (dart:core-patch/growable_array.dart:278:8)
#6      DataModelBuilder._validate (package:aqueduct/src/db/managed/builders/data_model_builder.dart:38:15)
#7      new DataModelBuilder (package:aqueduct/src/db/managed/builders/data_model_builder.dart:11:5)
#8      new ManagedDataModel.fromCurrentMirrorSystem (package:aqueduct/src/db/managed/data_model.dart:45:21)
#9      AqueductServerChannel.prepare (package:aqueduct_server/channel.dart:47:40)
<asynchronous suspension>
#10     ApplicationServer.start (package:aqueduct/src/application/application_server.dart:65:19)
<asynchronous suspension>
#11     Application.startOnCurrentIsolate (package:aqueduct/src/application/application.dart:128:20)
<asynchronous suspension>
#12     TestHarness.start (package:aqueduct_test/src/harness.dart:111:23)
<asynchronous suspension>
#13     TestHarness.install.<anonymous closure> (package:aqueduct_test/src/harness.dart:88:15)
<asynchronous suspension>
#14     Declarer._setUpAll.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:291:72)
#15     Future.forEach.<anonymous closure> (dart:async/future.dart:492:26)
#16     Future.doWhile.<anonymous closure> (dart:async/future.dart:534:26)
#17     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#18     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#19     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#20     _rootRunUnary (dart:async/zone.dart:1132:38)
#21     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#22     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#23     _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:968:26)
#24     Future.doWhile (dart:async/future.dart:549:18)
#25     Future.forEach (dart:async/future.dart:490:12)
#26     Declarer._setUpAll.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:291:36)
#27     _rootRun (dart:async/zone.dart:1124:13)
#28     _CustomZone.run (dart:async/zone.dart:1021:19)
#29     _runZoned (dart:async/zone.dart:1516:10)
#30     runZoned (dart:async/zone.dart:1463:12)
#31     Declarer._setUpAll.<anonymous closure> (package:test_api/src/backend/declarer.dart:291:14)
#32     Invoker._onRun.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/invoker.dart:400:25)
<asynchronous suspension>
#33     new Future.<anonymous closure> (dart:async/future.dart:176:37)
#34     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#35     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#36     _rootRun (dart:async/zone.dart:1120:38)
#37     _CustomZone.run (dart:async/zone.dart:1021:19)
#38     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#39     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#40     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#41     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#42     _rootRun (dart:async/zone.dart:1124:13)
#43     _CustomZone.run (dart:async/zone.dart:1021:19)
#44     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#45     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:21:15)
#46     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
#47     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#48     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)

i got the same error but with diffrent table ;d so something is wrong

@itsjoeconway
Copy link
Contributor

You need to specify the type parameter for ManagedSet. They are both ManagedSet<TeamPlayer> teamPlayers.

@moczix
Copy link
Author

moczix commented May 9, 2019

the relation is work fine, but its crashed after added this lines:

@serialize(input: false, output: true)
List players;

so how to fix it?

@moczix
Copy link
Author

moczix commented May 9, 2019

if you mean to change List -> ManagedSet, i did:

class Team extends ManagedObject<_Team> implements _Team {
  @Serialize(input: false, output: true)
  ManagedSet<Player> players;
}
class _Team {
  @primaryKey
  int id;

  String name;

  ManagedSet<TeamPlayer> teamPlayers;
}

// This type is a join table
class TeamPlayer extends ManagedObject<_TeamPlayer> implements _TeamPlayer {}
class _TeamPlayer {
  @primaryKey
  int id;  

  @Relate(#teamPlayers)
  Team team;

  @Relate(#teamPlayers)
  Player player;
}

class Player extends ManagedObject<_Player> implements _Player {}
class _Player {
  @primaryKey
  int id;

  String name;

  ManagedSet<TeamPlayer> teamPlayers;
}
[SEVERE] aqueduct: Data Model Error: Property 'players' on 'Team' has an unsupported type. This can occur when the type cannot be stored in a database, or when a relationship does not have a valid inverse. If this property is supposed to be a relationship,  ensure the inverse property annotation is 'Relate(#players, ...)'. If this is not supposed to be a relationship property, its type must be one of: String, DateTime, bool, int, double, Document. Instance of 'Application<AqueductServerChannel>' #0      PropertyBuilder.validate (package:aqueduct/src/db/managed/builders/property_builder.dart:89:9)
#1      EntityBuilder.validate.<anonymous closure> (package:aqueduct/src/db/managed/builders/entity_builder.dart:106:33)
#2      List.forEach (dart:core-patch/growable_array.dart:278:8)
#3      EntityBuilder.validate (package:aqueduct/src/db/managed/builders/entity_builder.dart:106:16)
#4      DataModelBuilder._validate.<anonymous closure> (package:aqueduct/src/db/managed/builders/data_model_builder.dart:38:32)
#5      List.forEach (dart:core-patch/growable_array.dart:278:8)
#6      DataModelBuilder._validate (package:aqueduct/src/db/managed/builders/data_model_builder.dart:38:15)
#7      new DataModelBuilder (package:aqueduct/src/db/managed/builders/data_model_builder.dart:11:5)
#8      new ManagedDataModel.fromCurrentMirrorSystem (package:aqueduct/src/db/managed/data_model.dart:45:21)
#9      AqueductServerChannel.prepare (package:aqueduct_server/channel.dart:47:40)
<asynchronous suspension>
#10     ApplicationServer.start (package:aqueduct/src/application/application_server.dart:65:19)
<asynchronous suspension>
#11     Application.startOnCurrentIsolate (package:aqueduct/src/application/application.dart:128:20)
<asynchronous suspension>
#12     TestHarness.start (package:aqueduct_test/src/harness.dart:111:23)
<asynchronous suspension>
#13     TestHarness.install.<anonymous closure> (package:aqueduct_test/src/harness.dart:88:15)
<asynchronous suspension>
#14     Declarer._setUpAll.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:291:72)
#15     Future.forEach.<anonymous closure> (dart:async/future.dart:492:26)
#16     Future.doWhile.<anonymous closure> (dart:async/future.dart:534:26)
#17     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#18     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#19     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#20     _rootRunUnary (dart:async/zone.dart:1132:38)
#21     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#22     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#23     _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:968:26)
#24     Future.doWhile (dart:async/future.dart:549:18)
#25     Future.forEach (dart:async/future.dart:490:12)
#26     Declarer._setUpAll.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:291:36)
#27     _rootRun (dart:async/zone.dart:1124:13)
#28     _CustomZone.run (dart:async/zone.dart:1021:19)
#29     _runZoned (dart:async/zone.dart:1516:10)
#30     runZoned (dart:async/zone.dart:1463:12)
#31     Declarer._setUpAll.<anonymous closure> (package:test_api/src/backend/declarer.dart:291:14)
#32     Invoker._onRun.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/invoker.dart:400:25)
<asynchronous suspension>
#33     new Future.<anonymous closure> (dart:async/future.dart:176:37)
#34     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#35     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#36     _rootRun (dart:async/zone.dart:1120:38)
#37     _CustomZone.run (dart:async/zone.dart:1021:19)
#38     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#39     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#40     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#41     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#42     _rootRun (dart:async/zone.dart:1124:13)
#43     _CustomZone.run (dart:async/zone.dart:1021:19)
#44     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#45     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:21:15)
#46     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
#47     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#48     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)

@itsjoeconway
Copy link
Contributor

The Slack channel (http://slackaqueductsignup.herokuapp.com/) is better for diagnosing user errors than GitHub issues. There are two issues you have.

  1. You are not providing the type arguments to your ManagedSet - if you re-read the example, you missed them.

  2. You are not providing an appropriate type for the transient property (players). There is an error in the documentation here that needs to be fixed. Will resolve this issue and post back here when resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants