Skip to content

Commit

Permalink
Fixed find spools not working if no vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
Donkie committed May 10, 2023
1 parent 514b238 commit 87690b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion spoolman/database/filament.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ async def find(
article_number: Optional[str] = None,
) -> list[models.Filament]:
"""Find a list of filament objects by search criteria."""
stmt = select(models.Filament).options(contains_eager(models.Filament.vendor)).join(models.Filament.vendor)
stmt = (
select(models.Filament)
.options(contains_eager(models.Filament.vendor))
.join(models.Filament.vendor, isouter=True)
)
if vendor_name is not None:
stmt = stmt.where(models.Vendor.name.ilike(f"%{vendor_name}%"))
if vendor_id is not None:
Expand Down
4 changes: 2 additions & 2 deletions spoolman/database/spool.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ async def find(
"""Find a list of spool objects by search criteria."""
stmt = (
sqlalchemy.select(models.Spool)
.join(models.Spool.filament)
.join(models.Filament.vendor)
.join(models.Spool.filament, isouter=True)
.join(models.Filament.vendor, isouter=True)
.options(contains_eager(models.Spool.filament).contains_eager(models.Filament.vendor))
)
if filament_name is not None:
Expand Down

0 comments on commit 87690b0

Please sign in to comment.