title: Flask-SQLAlchemy ON DELETE SET DEFAULT
body: <p>I have two simple tables in Postgre DB:
  User and Role with relation many to one with following code behind:</p>
  
  <pre><code>    class User(db.Model):
  
          id = db.Column(db.Integer, primary_key=True, nullable=False)
          created = db.Column(db.DateTime, nullable=False, default=datetime.datetime.now)
          username = db.Column(db.String(80), unique=True, nullable=False)
          password = db.Column(db.String(256), unique=False, nullable=False)
          email = db.Column(db.String(120), unique=True, nullable=True)
          active = db.Column(db.Boolean, nullable=False, default=True)
          role_id = db.Column(db.Integer, db.ForeignKey('role.id', ondelete='SET DEFAULT'), server_default = '1', nullable = False)
  
          role = db.relationship('Role', backref = db.backref('users', lazy = True), passive_deletes = True)
  </code></pre>
  
  <p>And </p>
  
  <pre><code>class Role(db.Model):
  
      id = db.Column(db.Integer, primary_key=True, nullable=False)
      slug = db.Column(db.String, nullable=False)
  </code></pre>
  
  <p>ON DELETE SET DEFAULT constraint on DB acts correctly however SA is forcing NULL update to role_id BEFORE deletion take place, rising integrity error.</p>
  
  <pre><code>2018-09-25 14:08:54,922 INFO sqlalchemy.engine.base.Engine UPDATE "user" SET role_id=%(role_id)s WHERE "user".id = %(user_id)s
  2018-09-25 14:08:54,922 INFO sqlalchemy.engine.base.Engine {'role_id': None, 'user_id': 2}
  </code></pre>
  
  <p>I've tried cascade options and passive_deletes with no effect. What should be the correct approach?</p>