Skip to content

Commit 261755c

Browse files
committed
.
1 parent 48f5302 commit 261755c

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

examples/sqlalchemy_soft_delete/README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,38 @@ join_methods = {"join", "outerjoin", "innerjoin"}
8484

8585
## Code Transformations
8686

87-
### Simple Join
87+
### Simple Join with Model Reference
8888
```python
8989
# Before
90-
query.join(User)
90+
query.join(Project, Session.project)
9191

9292
# After
9393
from sqlalchemy import and_
94-
query.join(User, User.deleted_at.is_(None))
94+
query.join(Project, and_(Session.project, Project.deleted_at.is_(None)))
9595
```
9696

97-
### Join with Existing Condition
97+
### Join with Column Equality
9898
```python
9999
# Before
100-
query.join(User, User.id == Post.user_id)
100+
query.join(Project, Session.project_id == Project.id)
101101

102102
# After
103103
from sqlalchemy import and_
104-
query.join(User, and_(User.id == Post.user_id, User.deleted_at.is_(None)))
104+
query.join(Project, and_(Session.project_id == Project.id, Project.deleted_at.is_(None)))
105+
```
106+
107+
### Multiple Joins in Query Chain
108+
```python
109+
# Before
110+
Session.query.join(Project, Session.project)\
111+
.join(Account, Project.account)\
112+
.outerjoin(Proposal, Session.proposal)
113+
114+
# After
115+
from sqlalchemy import and_
116+
Session.query.join(Project, and_(Session.project, Project.deleted_at.is_(None)))\
117+
.join(Account, Project.account)\
118+
.outerjoin(Proposal, and_(Session.proposal, Proposal.deleted_at.is_(None)))
105119
```
106120

107121
## Graph Disable Mode

0 commit comments

Comments
 (0)