Skip to content

Implement __eq__ on on Table  #1075

@Skelmis

Description

@Skelmis

It'd be lovely to be able to compare table instances at a top level without the need to dive down into attributes. Further, users could always override the default id comparison on tables if they do special things.

An example use case of mine:

    @post(
        path="/{project_id:str}/settings/toggle_public_view",
        include_in_schema=False,
    )
    async def toggle_public_view(self, request: Request, project_id: str) -> Redirect:
        project, redirect = await self.get_project(request, project_id)
        if redirect:
            return redirect

        if project.owner != request.user:
            alert(
                request,
                "You must be the project owner to change project visibility.",
                level="error",
            )
            return project.redirect_to()

However with the current behavior the following occurs:

        project.owner.id == request.user.id -> True
        project.owner == request.user -> False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions