Back

Most likely a bug with attributes relationship

  • 0
  • Databases
  • Functions
jekalat
31 May, 2023, 15:55

Ran into this bug. When I did an update of the document in the collection, I mistakenly passed other id to the relationship attribute. After that I won't be able to clear that attribute into an empty array. these undefined fields in the array remained all the time, and after I add right ids. You can see it in the pictures below. Only deleting the document helped

TL;DR
There seems to be a bug with the attributes relationship. The user mistakenly passed the wrong ID to the relationship attribute, causing undefined fields in the array. Refreshing the page did not resolve the issue. The only solution was to delete the document. A bug report was suggested.
Drake
31 May, 2023, 16:03

Interesting...was it still there after refreshing the page?

jekalat
31 May, 2023, 16:05

Yes

jekalat
31 May, 2023, 16:05

I cant delete them from ui too

jekalat
31 May, 2023, 16:07

I'll try now to reproduce and refresh the whole page

Drake
31 May, 2023, 16:10

interesting...from my experience, the relationship doesn't save if the document ID doesn't exist 🧐

jekalat
31 May, 2023, 16:23

I did a repeat. Yes, undefined again. and I sent not ids but an array of strings (I mixed up the arrays when this first happened)

jekalat
31 May, 2023, 16:30

@Steven I can send to you video, how it works. When I try delete, after that window freeze, and I refresh window

Drake
1 Jun, 2023, 18:50

array of strings? What od you mean exactly? and can you share the JSON response for the get document api call for this document?

jekalat
1 Jun, 2023, 19:48

JSON:

{ "user_id" : "6477728b7ed36c3d3b05", "$id" : "6477728bbbc03f383897", "device_id" : null, "deleted" : false, "background" : null, "$createdAt" : "2023-05-31T16:15:07.769+00:00", "$updatedAt" : "2023-05-31T16:21:21.672+00:00", "$collectionId" : "644ccfb5873757ec93fa", "active_status" : false, "phone" : null, "chatRooms" : [

], "nick_name" : "testA", "created_by" : "64763abdbfa4ab03e718", ||"role_id" : [ { "$collectionId" : "6450c122e4cc1bf2e41a", "$databaseId" : "644ccfacafd0a0087649" }, { "$collectionId" : "6450c122e4cc1bf2e41a", "$databaseId" : "644ccfacafd0a0087649" } ],|| "first_name" : "first", "$databaseId" : "644ccfacafd0a0087649", "team_id" : "646e0dad7c68c11a09ba", "$permissions" : [

] }

jekalat
1 Jun, 2023, 19:54
jekalat
1 Jun, 2023, 19:55

const update_user = await database.updateDocument(db_id, db_users_id, user_document_id, {'team_id':payload.team_id, 'role_id':role_ids, "updated_by":by_user});

jekalat
1 Jun, 2023, 19:57

role_ids: ["645e5f3f1e810c950493", "644ccfb5873757ec93fa"] must be like this, but was by mistake role_ids: ["admin","manager"]

jekalat
1 Jun, 2023, 19:57

@Steven

jekalat
1 Jun, 2023, 20:11

Attribute role_id is Relationship (many to many)

Drake
1 Jun, 2023, 21:02

make sure to use 3 back ticks for multi line code

Drake
1 Jun, 2023, 21:15

ah that was it...

Drake
1 Jun, 2023, 21:16

would you please create an issue for this and include all this info?

Drake
1 Jun, 2023, 21:19
jekalat
1 Jun, 2023, 21:39

Yes, of course I will do it tomorrow

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