user14038884
user14038884

Reputation:

How Update the required array in the database column (Integer)

I welcome everyone, I have a column with an array and type Bigint, I tried to update the desired array but got an error, how can I do it right?

#My column
statistics = ArrayField(BigIntegerField, default=[0, 0, 0, 0, 0, 0])

#My try
await db.execute(MarriagePlayer.update({
     MarriagePlayer.statistics[0]: MarriagePlayer.statistics[0] + 1
}).where(
      MarriagePlayer.chat_id == msg.receiver_id,
      MarriagePlayer.user_id << [msg.sender_id, p.loved]))

and my error:

MarriagePlayer.statistics[0]: MarriagePlayer.statistics[0] + 1

TypeError: unhashable type: 'ObjectSlice'

Upvotes: 0

Views: 64

Answers (1)

coleifer
coleifer

Reputation: 26245

There was a missing method implementation which prevented slice expressions from being used as dict keys. This is now fixed in master:

https://github.com/coleifer/peewee/commit/7eb7498018b4265ce7e79c3e2b0b90a93d622d45

The fix will be included in the next release as well.

Upvotes: 0

Related Questions