jaguar_orm icon indicating copy to clipboard operation
jaguar_orm copied to clipboard

Problem generating one-to-one relationship

Open agilob opened this issue 4 years ago • 1 comments

pub run build_runner build 
[INFO] Generating build script completed, took 615ms
[INFO] Reading cached asset graph completed, took 98ms
[INFO] Checking for updates since last build completed, took 820ms
[WARNING] jaguar_orm_gen:jaguar_orm_gen on lib/core/person/person_bean.dart:
Generating bean for PersonBean ...
[WARNING] jaguar_orm_gen:jaguar_orm_gen on lib/core/person_settings/person_settings_bean.dart:
Generating bean for PersonSettingsBean ...
[INFO] Running build completed, took 3.9s
[INFO] Caching finalized dependency graph completed, took 69ms
[INFO] Succeeded after 4.0s with 10 outputs (32 actions)
lib/core/person/person_bean.dart:8:44: Error: Type '_PersonBean' not found.
class PersonBean extends Bean<Person> with _PersonBean {
^^^^^^^^^^^
lib/core/person_settings/person_settings_bean.dart:8:60: Error: Type '_PersonSettingsBean' not found.
class PersonSettingsBean extends Bean<PersonSettings> with _PersonSettingsBean {
^^^^^^^^^^^^^^^^^^^
lib/core/person/person_bean.dart:8:7: Error: The type '_PersonBean' can't be mixed in.
class PersonBean extends Bean<Person> with _PersonBean {
^
lib/core/person_settings/person_settings_bean.dart:8:7: Error: The type '_PersonSettingsBean' can't be mixed in.
class PersonSettingsBean extends Bean<PersonSettings> with _PersonSettingsBean {
^
lib/core/person/person_bean.dart:8:7: Error: The non-abstract class 'PersonBean' is missing implementations for these members:
- Bean.fields                                                                                                                                                                                                                                     
- Bean.fromMap                                                                                                                                                                                                                                    
- Bean.toSetColumns                                                                                                                                                                                                                               
Try to either                                                                                                                                                                                                                                      
- provide an implementation,                                                                                                                                                                                                                      
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.

class PersonBean extends Bean<Person> with _PersonBean {
^^^^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/jaguar_query-2.2.9/lib/src/bean/bean.dart:101:26: Context: 'Bean.fields' is defined here.
Map<String, Field> get fields;
^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/jaguar_query-2.2.9/lib/src/bean/bean.dart:104:13: Context: 'Bean.fromMap' is defined here.
ModelType fromMap(Map map);
^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/jaguar_query-2.2.9/lib/src/bean/bean.dart:108:19: Context: 'Bean.toSetColumns' is defined here.
List<SetColumn> toSetColumns(ModelType model,
^^^^^^^^^^^^
lib/core/person_settings/person_settings_bean.dart:8:7: Error: The non-abstract class 'PersonSettingsBean' is missing implementations for these members:
- Bean.fields
- Bean.fromMap
- Bean.toSetColumns
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.

class PersonSettingsBean extends Bean<PersonSettings> with _PersonSettingsBean {
^^^^^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dartlang.org/jaguar_query-2.2.9/lib/src/bean/bean.dart:101:26: Context: 'Bean.fields' is defined here.
Map<String, Field> get fields;

person:

class Person {
  static const String tableName = 'person';

  @PrimaryKey(auto: true, name: 'person_id')
  int id;

  @HasOne(PersonSettingsBean)
  PersonSettings personSettings;

person settings:

class PersonSettings {
  static const String tableName = 'person_settings';

  @PrimaryKey(auto: true, name: 'person_settings_id')
  int id;

  @BelongsTo(PersonBean)
  int personId;

person bean:

import 'package:jaguar_orm/jaguar_orm.dart';

part 'person_bean.jorm.dart';

@GenBean()
class PersonBean extends Bean<Person> with _PersonBean {
  final PersonSettingsBean personSettingsBean;

  PersonBean(Adapter adapter)
      : personSettingsBean = new PersonSettingsBean(adapter),
      : super(adapter);

  @override
  String tableName = 'person';
}

person settings bean:

import 'package:jaguar_orm/jaguar_orm.dart';
import 'package:jaguar_query/jaguar_query.dart';

part 'person_settings_bean.jorm.dart';

@GenBean()
class PersonSettingsBean extends Bean<PersonSettings> with _PersonSettingsBean {
  PersonSettingsBean(Adapter adapter) : super(adapter);

  @override
  String tableName = 'person_settings';
}

dependencies:

environment:
  sdk: ">=2.5.0 <3.0.0"

dependencies:
  args: ^1.5.0
  injector: ^1.0.8
  dotenv: ^2.0.0
  json_serializable: ^3.2.2
  postgres: ^1.0.0
  shelf: ^0.7.5
  timezone: ^0.5.6
  shelf_router: ^0.7.0+1
  jaguar_query: ^2.2.9
  jaguar_orm: ^2.2.7
  jaguar_orm_gen: ^2.2.30
  jaguar_query_postgres: ^2.2.6

dev_dependencies:
  shelf_router_generator: ^0.7.0+1
  build_runner: 1.7.2
  build_test: 0.10.8
  test: 1.9.4
  pedantic: 1.9.0
  grinder: 0.8.3+1

agilob avatar Dec 22 '19 21:12 agilob

This question has been open since December... I could really do with an answer to this too!

TheDevelolper avatar Jun 07 '20 21:06 TheDevelolper