Skip to content

Commit a204992

Browse files
authored
Add the select from to join condition (#76)
1 parent f6222d1 commit a204992

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sqlalchemy_crud_plus/crud.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ async def count(
196196
stmt = stmt.where(*filters)
197197

198198
if join_conditions:
199-
stmt = apply_join_conditions(self.model, stmt, join_conditions)
199+
stmt = apply_join_conditions(self.model, stmt.select_from(self.model), join_conditions)
200200

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

228228
if join_conditions:
229-
stmt = apply_join_conditions(self.model, stmt, join_conditions)
229+
stmt = apply_join_conditions(self.model, stmt.select_from(self.model), join_conditions)
230230

231231
query = await session.execute(stmt)
232232
return query.scalars().first() is not None
@@ -265,7 +265,7 @@ async def select_model(
265265
stmt = stmt.options(*load_options)
266266

267267
if join_conditions:
268-
stmt = apply_join_conditions(self.model, stmt, join_conditions)
268+
stmt = apply_join_conditions(self.model, stmt.select_from(self.model), join_conditions)
269269

270270
if load_strategies:
271271
rel_options = build_load_strategies(self.model, load_strategies)
@@ -339,7 +339,7 @@ async def select(
339339
stmt = select(self.model).where(*filters)
340340

341341
if join_conditions:
342-
stmt = apply_join_conditions(self.model, stmt, join_conditions)
342+
stmt = apply_join_conditions(self.model, stmt.select_from(self.model), join_conditions)
343343

344344
if load_options:
345345
stmt = stmt.options(*load_options)

0 commit comments

Comments
 (0)