From 14c3cc9e58d403e38ff657a4d9737a6893d5289b Mon Sep 17 00:00:00 2001 From: Agustin Arce Date: Mon, 14 Oct 2024 11:47:54 -0300 Subject: [PATCH] refactor: add __eq__ on Table --- piccolo/table.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/piccolo/table.py b/piccolo/table.py index bae9b8a4..22e742a3 100644 --- a/piccolo/table.py +++ b/piccolo/table.py @@ -851,6 +851,13 @@ def __repr__(self) -> str: ) return f"<{self.__class__.__name__}: {pk}>" + def __eq__(self, other: Table): + return ( + isinstance(other, self.__class__) + and self.__class__._meta.primary_key + == other.__class__._meta.primary_key + ) + ########################################################################### # Classmethods