Skip to content

Commit

Permalink
Merge pull request #6 from aarhusstadsarkiv/hotfix-for-convertool
Browse files Browse the repository at this point in the history
Hotfix: removed strict = True from all zip() operations, since it cau…
  • Loading branch information
Magniler authored Sep 6, 2023
2 parents 6f28d0f + 2b25df3 commit 0f51f2b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions acacore/database/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def fetchalltuples(self) -> Generator[tuple, None, None]:
Returns:
Generator: A generator for the tuples in the cursor.
"""
return (tuple(c.from_entry(v) for c, v in zip(self.columns, vs, strict=True)) for vs in self.cursor.fetchall())
return (tuple(c.from_entry(v) for c, v in zip(self.columns, vs)) for vs in self.cursor.fetchall())

def fetchonetuple(self) -> Optional[tuple]:
"""
Expand All @@ -58,7 +58,7 @@ def fetchonetuple(self) -> Optional[tuple]:
"""
vs: tuple = self.cursor.fetchone()

return tuple(c.from_entry(v) for c, v in zip(self.columns, vs, strict=True)) if vs else None
return tuple(c.from_entry(v) for c, v in zip(self.columns, vs)) if vs else None

@overload
def fetchall(self) -> Generator[dict[str, Any], None, None]:
Expand All @@ -83,14 +83,13 @@ def fetchall(self, model: Optional[Type[M]] = None) -> Generator[Union[dict[str,
if model:
return (
model.model_validate(
{c.alias or c.name: v for c, v in zip(select_columns, vs, strict=True)},
{c.alias or c.name: v for c, v in zip(select_columns, vs)},
)
for vs in self.cursor.fetchall()
)

return (
{c.alias or c.name: c.from_entry(v) for c, v in zip(select_columns, vs, strict=True)}
for vs in self.cursor.fetchall()
{c.alias or c.name: c.from_entry(v) for c, v in zip(select_columns, vs)} for vs in self.cursor.fetchall()
)

@overload
Expand Down Expand Up @@ -120,7 +119,7 @@ def fetchone(
if vs is None:
return None

entry: dict[str, Any] = {c.name: c.from_entry(v) for c, v in zip(select_columns, vs, strict=True)}
entry: dict[str, Any] = {c.name: c.from_entry(v) for c, v in zip(select_columns, vs)}

return model.model_validate(entry) if model else entry

Expand Down

0 comments on commit 0f51f2b

Please sign in to comment.