Skip to content

Commit

Permalink
VERSION = (3, 2, 0)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinch WU committed Feb 3, 2024
1 parent 2a9edb0 commit cd475e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rinch_sql/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (3, 1, 0)
VERSION = (3, 2, 0)

__version__ = ".".join(map(str, VERSION))

Expand Down
11 changes: 11 additions & 0 deletions rinch_sql/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ def select(self, _where: str) -> list[T]:
obj_list = [self._values_2_obj(fields, i) for i in data_list]
return obj_list

def select_by_uk(self, obj: T) -> list[T]:
uk_list = self.sql.field_list_unique
eq_list = [f"`{x}`=%s" for x in uk_list]
_where = " AND ".join(eq_list)
values = self._obj_2_values(obj, uk_list)

sql, fields = self.sql.select(_where)
data_list = self.execute(sql, values)
obj_list = [self._values_2_obj(fields, i) for i in data_list]
return obj_list

def insert(self, obj_list: list[T]) -> None:
sql, fields = self.sql.insert()
values_list = [self._obj_2_values(obj, fields) for obj in obj_list]
Expand Down
2 changes: 1 addition & 1 deletion rinch_sql/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __hash__(self):

def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__tuple__() == other.__tuple__()
return tuple(self) == tuple(other)
else:
return False

Expand Down

0 comments on commit cd475e5

Please sign in to comment.