Back

Inconsistent format when retrieving child relationship attribute

  • 0
  • Databases
  • Flutter
  • Cloud
anmot.
13 Mar, 2024, 01:31

Let's say we have a collection called Users and it has an attribute called private which has one-to-one relation with PrivateUserInfo collection.

Users collection (parent) -> private attribute -> PrivateUserInfo collection (child)

A user has read access on Users collection but not on PrivateUserInfo (child) collection. There is an inconsistency on how this child attribute (private) is returned when calling getDocument vs listDocuments on Users collections.

✅ listDocuments: private -> null

❌ getDocument: private -> []

Ideally as this is one-to-one relationship, we expect the child attribute to be either null or Map but due to this inconsistency, it results in

List<dynamic>' is not a subtype of type 'Map<String, dynamic> in type cast in Flutter.

TL;DR
Developers are experiencing inconsistent behavior when retrieving a child relationship attribute in Flutter. When using listDocuments, the child attribute returns null, which is correct. However, when using getDocument, the child attribute returns an empty array, causing type cast errors. This inconsistency needs to be addressed.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more