Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sqlalchemy_crud_plus/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async def count(
stmt = stmt.where(*filters)

if join_conditions:
stmt = apply_join_conditions(self.model, stmt, join_conditions)
stmt = apply_join_conditions(self.model, stmt.select_from(self.model), join_conditions)

query = await session.execute(stmt)
total_count = query.scalar()
Expand Down Expand Up @@ -226,7 +226,7 @@ async def exists(
stmt = select(self.model).where(*filters).limit(1)

if join_conditions:
stmt = apply_join_conditions(self.model, stmt, join_conditions)
stmt = apply_join_conditions(self.model, stmt.select_from(self.model), join_conditions)

query = await session.execute(stmt)
return query.scalars().first() is not None
Expand Down Expand Up @@ -265,7 +265,7 @@ async def select_model(
stmt = stmt.options(*load_options)

if join_conditions:
stmt = apply_join_conditions(self.model, stmt, join_conditions)
stmt = apply_join_conditions(self.model, stmt.select_from(self.model), join_conditions)

if load_strategies:
rel_options = build_load_strategies(self.model, load_strategies)
Expand Down Expand Up @@ -339,7 +339,7 @@ async def select(
stmt = select(self.model).where(*filters)

if join_conditions:
stmt = apply_join_conditions(self.model, stmt, join_conditions)
stmt = apply_join_conditions(self.model, stmt.select_from(self.model), join_conditions)

if load_options:
stmt = stmt.options(*load_options)
Expand Down