Skip to content

getRelation with error: Invalid Relation key name #801

Closed
@catalunha

Description

@catalunha

I'm building a tutorial for Parse Serve (using Back4app) and ran into this issue on SKD for Flutter.

New Issue Checklist

Issue Description

I tested the following code. All very well.

    log('addRelation 01');
    final parseObjectBook01 = ParseObject(BookEntity.className);
    parseObjectBook01.objectId = 'aeOTTuGO7r';
    final parseObjectAuthor01 = ParseObject(AuthorEntity.className);
    parseObjectAuthor01.objectId = 'fK4I00NlBy';
    parseObjectBook01.addRelation('typeRelationAuthor', [parseObjectAuthor01]);
    await parseObjectBook01.save();

But this code. It generates error. Informed below.

    log('addRelation 01a');
    final parseObjectBook01 = ParseObject(BookEntity.className);
    parseObjectBook01.objectId = 'aeOTTuGO7r';
    var parseRelationBook = parseObjectBook01.getRelation('typeRelationAuthor');
    final parseObjectAuthor01 = ParseObject(AuthorEntity.className);
    parseObjectAuthor01.objectId = 'fK4I00NlBy';
    parseRelationBook.add(parseObjectAuthor01);
    await parseObjectBook01.save();

image
Exactly on this line:
var parseRelationBook = parseObjectBook01.getRelation('typeRelationAuthor');
image

Steps to reproduce

Create a pure standard Dart project with VSCode
Create a basic project in back4app and write down the appId and clientKey.
Copy the code above to your Dart project and enter the correct appId and clientKey and then a wrong value.
Run the Dart project with:
$ dart bin/learning_about_b4a_dart.dart

Actual Outcome

Error

Expected Outcome

May the result be the same. In both codes

Environment

Parse Flutter SDK

  • SDK version: parse_server_sdk_flutter: ^3.1.3
  • Operating system version: Description: Pop!_OS 22.04 LTS

Server

  • Parse Server version: 4.5.0

Logs

Connecting to VM Service at http://127.0.0.1:35555/jjn-YZQ6Y-s=/
[log] Back4app Connected.
[log] addRelation 01a
Unhandled exception:
Invalid Relation key name
#0 new ParseRelation
package:parse_server_sdk/…/objects/parse_relation.dart:7
#1 ParseObject.getRelation
package:parse_server_sdk/…/objects/parse_object.dart:313
#2 BookAddData.addRelations2
package:learning_about_b4a_dart/…/book/book_add_data.dart:108
#3 main
bin/learning_about_b4a_dart.dart:81

Exited (255)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:questionSupport or code-level question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions