Skip to content

Feature: Defining Equals (and local deletion of QuerySet) #151

Open
@SovcikJoe

Description

@SovcikJoe

Hi Miles,

so I noticed a while back that if I want to compare two Objects I get False no matter what I do, unless I directly compare their objectId's for example.

So I wanted to implement this myself using

  def __hash__(self):
        return hash(self.obj)

    def __eq__(self,other):
        pdb.set_trace()
        print('__eq__()')
        return self.objectId == other.objectId

And I added this code to query.Queryset as I am working with Querysets.
(BTW pdb is there just so I can see what's going on but the code never gets triggered)

So then I would expect that if I do

queryset[0] == samequeryset[0]

That it would return True. But it still keeps returning False.

As I am guessing I am not understanding something here, I also added the code to ParseType and QueryManager.
To no appeal.

Do you know which object would be a proper place to put this code in?

I was also implementing a (local)delete function for Queryset [ something like list.remove(x) ]as well as that's something I needed badly.
And I got something now so I was wondering if you'd be interested in me submitting this (and adding it to the , I am guessing , Queryset Class.
I already tried using delitem method with no success again so I just implemented a public function for myself.

I would love to contribute so let me know what you think/potential feedback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions