Back

[2-way relationships] Unknown column 'column_name' in 'field list'

  • 0
  • Databases
  • Self Hosted
Drake
22 Nov, 2023, 15:07

Did you make any changes to the collection or attributes after creating this relationship?

TL;DR
The user is experiencing an error when trying to delete an object that has a two-way relationship with activities. The error message states "Unknown column 'object' in 'field list'". The user has tried removing the third relationship and checking if it is causing the problem, but the issue persists. They are using the appwrite web console to add and remove objects, and adding objects works fine but deleting them throws errors. Solution: The user is unsure if this is a bug or a configuration issue. One possible solution suggested by another user is to directly delete the object from the database. Additionally, the user asks if deleting and recreating the
bugs_cena
22 Nov, 2023, 15:15

I may have deleted it and recreated (on an empty collection)

Drake
22 Nov, 2023, 15:15

That could be the problem

Drake
22 Nov, 2023, 15:16

Ideally this attribute should have been deleted too

bugs_cena
22 Nov, 2023, 15:17

Is there a work-around to delete the document - in this current state?

bugs_cena
22 Nov, 2023, 15:17

Is deleting the collection and recreating it from scratch the only solution?

Drake
22 Nov, 2023, 15:20

What's the current value for the attribute?

bugs_cena
22 Nov, 2023, 15:21

I didn't get you. what do you mean by value?

Drake
22 Nov, 2023, 15:21

What's the result of getDocument?

bugs_cena
22 Nov, 2023, 15:23

empty list []

Drake
22 Nov, 2023, 15:24

You might have to go directly into the database to delete it then

bugs_cena
22 Nov, 2023, 15:45

I'm not sure if this is an issue from the way I'm configuring or may be it should be documented as to how the relationships can be cleaned up. The other table gives this error:

TypeScript
[Error] Message: Unknown column 'object' in 'field list'
bugs_cena
22 Nov, 2023, 15:46

What I mean is - I'm not sure if I should be reporting this as a bug?

bugs_cena
22 Nov, 2023, 16:55

@Drake ^^

bugs_cena
22 Nov, 2023, 17:02

This issue persists even when both the collections are created from scratch and the relationships added.

Drake
22 Nov, 2023, 17:12

what's yoour code and what are your collections (as JSON)?

bugs_cena
22 Nov, 2023, 17:24

Table 1

TypeScript
{
    "$id": "654c9bc06a5b9d7a7c8d",
    "name": "feed_activities",
    "enabled": true,
    "documentSecurity": false,
    "attributes": [
        {
            "key": "name",
            "type": "string",
            "status": "available",
            "error": "",
            "required": false,
            "array": false,
            "size": 64,
            "default": null
        },
        {
            "key": "result",
            "type": "string",
            "status": "available",
            "error": "",
            "required": false,
            "array": false,
            "size": 524288,
            "default": null
        },
        {
            "key": "notify",
            "type": "boolean",
            "status": "available",
            "error": "",
            "required": false,
            "array": false,
            "default": null
        },
        {
            "key": "actor",
            "type": "relationship",
            "status": "available",
            "error": "",
            "required": false,
            "array": false,
            "relatedCollection": "654c9aa06a5b9e7a7c8c",
            "relationType": "manyToMany",
            "twoWay": true,
            "twoWayKey": "activities",
            "onDelete": "setNull",
            "side": "parent"
        },
        {
            "key": "object",
            "type": "relationship",
            "status": "available",
            "error": "",
            "required": false,
            "array": false,
            "relatedCollection": "65570c6420b88746ea8d",
            "relationType": "oneToMany",
            "twoWay": true,
            "twoWayKey": "activities",
            "onDelete": "cascade",
            "side": "child"
        }
    ],
    "indexes": []
}
bugs_cena
22 Nov, 2023, 17:25

Table 2

TypeScript
{
    "$id": "65570c6420b88746ea8d",
    "$permissions": [
        "read(\"users\")"
    ],
    "name": "feed_objects",
    "enabled": true,
    "documentSecurity": true,
    "attributes": [
        {
            "key": "type",
            "type": "string",
            "status": "available",
            "error": "",
            "required": false,
            "array": false,
            "size": 16,
            "default": "Object"
        },
        {
            "key": "name",
            "type": "string",
            "status": "available",
            "error": "",
            "required": false,
            "array": false,
            "size": 32,
            "default": null
        },
        {
            "key": "actor",
            "type": "relationship",
            "status": "available",
            "error": "",
            "required": false,
            "array": false,
            "relatedCollection": "654c9aa06a5b9e7a7c8c",
            "relationType": "oneToMany",
            "twoWay": false,
            "twoWayKey": "65570c6420b88746ea8d",
            "onDelete": "setNull",
            "side": "parent"
        },
        {
            "key": "activities",
            "type": "relationship",
            "status": "available",
            "error": "",
            "required": false,
            "array": false,
            "relatedCollection": "654c9bc06a5b9d7a7c8d",
            "relationType": "oneToMany",
            "twoWay": true,
            "twoWayKey": "object",
            "onDelete": "cascade",
            "side": "parent"
        }
    ],
    "indexes": [
        
    ]
}
bugs_cena
22 Nov, 2023, 17:52

I'm not using any code - just using appwrite web console to add/remove. Add works fine. But delete throws errors.

Drake
22 Nov, 2023, 18:37

What are you doing exactly?

bugs_cena
22 Nov, 2023, 18:45

I have 2 tables that have this 2 way relationships - Object has activities and activity belongs to an object. When I create an object, I also add zero or more activities. When I try to delete the obejct it throws the error I have mentioned in the summary of this discussion.

Drake
22 Nov, 2023, 18:48
Drake
22 Nov, 2023, 18:49

I was able to successfully add and remove (link/unlink) documents as well as delete documents without any error 🧐

Drake
22 Nov, 2023, 18:50

could the problem be with the 3rd relationship you have?

bugs_cena
23 Nov, 2023, 03:38

I'll try removing the 3rd relationship and check.

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