title: How to prevent SQLAlchemy default cascade behavior? FastAPI
body: <p>This is my parent class :</p>
  <pre><code>class Parent():
      name ...
      desc ...
      child = relationship(&quot;Child&quot;,back_populates=&quot;parent&quot;)
  </code></pre>
  <p>This is my child class :</p>
  <pre><code>class Child():
      parent_id ...
      parent = relationship(&quot;Parent&quot;,back_populates=&quot;child&quot;)
      ...
  </code></pre>
  <p>When I delete the parent class by using session.delete(), the related fields are all set to null. In the documentation it said &quot;It is a default behavior&quot;. Interesting thing is that when I try to delete it with Query.delete(synchronize_session=False), the deletion don't work and throw an error.</p>
  <p>Is there a way make the parent class not deletable just like Query.delete(synchronize_session=False) with session.delete()?</p>