Back

Query.not_equal() doesn't work with a list? [SOLVED]

  • 0
  • Databases
Infinil
23 Jun, 2023, 05:21

I have been using python appwrite sdk and for some reason the Query.not_equal() does not filter out the values for attribute in list.. is this a bug or error from my side?

TypeScript
docs = bot.appwrite_databases.list_documents(
    DISCORD_DATABASE_ID,
    COMMAND_USAGE_COLLECTION_ID,
    queries=[
      Query.is_not_null('user_id'),
      Query.not_equal('user_id', ['854259184141074472', '1088367284357177404']),
    ]
  )```
TL;DR
The user is reporting that Query.not_equal() does not work with a list in the Python Appwrite SDK. There is a suggestion to add two not_equal queries with the same field, but it is clarified that this logic does not make sense and will always resolve to True. The user also mentions that Query.equal() works with the list of values correctly. There is no solution mentioned in the thread.
Infinil
23 Jun, 2023, 05:21

so the docs with those user_ids still show..

Infinil
23 Jun, 2023, 05:21

there is no error hence i didnt share any exception ss

Infinil
23 Jun, 2023, 05:22

also Query.equal works with that list of user ids

Drake
23 Jun, 2023, 15:10

this

TypeScript
Query.not_equal('user_id', ['854259184141074472', '1088367284357177404']

means

TypeScript
user_id != '854259184141074472" OR user_id != '1088367284357177404'

which will always resolve to True

Drake
23 Jun, 2023, 15:10

in practice. it doesn't make sense to pass a list to not_equal

luckycadow
23 Jun, 2023, 15:20

Then why does it take an array? I would have assumed this was using not in.

Infinil
23 Jun, 2023, 15:28

Oh but with that logic Query.equal() seems weird as well since it is meant for matching any of the values in list because of OR operation but Query.not_equal() will not work with each value separately

Infinil
23 Jun, 2023, 15:29

Maybe the not_equal() should follow AND operation instead

Binyamin
23 Jun, 2023, 15:30

Try to add two not_equal like so

TypeScript
docs = bot.appwrite_databases.list_documents(
    DISCORD_DATABASE_ID,
    COMMAND_USAGE_COLLECTION_ID,
    queries=[
      Query.is_not_null('user_id'),
      Query.not_equal('user_id', ['854259184141074472']),
      Query.not_equal('user_id', ['1088367284357177404']),
    ]
  )
Infinil
23 Jun, 2023, 15:31

I can do that but for big lists that seems weird .. but yea ig i can iterate through and add the query for each value in my queries variable

Infinil
23 Jun, 2023, 15:31

Thanks for the help

Binyamin
23 Jun, 2023, 15:32

Yes, I agree it can look too much just for that.

Infinil
23 Jun, 2023, 15:33

But all good since it does the job

Infinil
23 Jun, 2023, 15:34

How do you close the forum 😅

Binyamin
23 Jun, 2023, 15:34

<a:agooglethumbsup:635256484682530825>

Binyamin
23 Jun, 2023, 15:34

Click Edit here And add [SOLVED] in front of the question

Binyamin
23 Jun, 2023, 15:34

Or you mean something else?

Infinil
23 Jun, 2023, 15:35

Ohh thanks

Infinil
23 Jun, 2023, 15:35

Query.not_equal() doesn't work with a list? [SOLVED]

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