title: SQLite: Foreign Key "ON DELETE SET NULL" action not getting triggered
body: <p><strong>Why is <code>ON DELETE SET NULL</code> failing when deleting a row via the application code, but it behaves correctly when manually executing an SQL statement?</strong></p>
  
  <p>I have a todo table and a category table. The todo table has a <code>category_id</code> foreign key that references <code>id</code> in the category table, and it was created with the "ON DELETE SET NULL" action.</p>
  
  <pre class="lang-sql prettyprint-override"><code>create table `category` (
    `id` integer not null primary key autoincrement,
    `name` varchar(255) not null
  );
  </code></pre>
  
  <pre class="lang-sql prettyprint-override"><code>create table `todo` (
    `id` integer not null primary key autoincrement,
    `title` varchar(255) not null,
    `complete` boolean not null default '0',
    `category_id` integer,
    foreign key(`category_id`) references `category`(`id`) on delete SET NULL on update CASCADE
  );
  </code></pre>
  
  <p>I also have an endpoint in my application that allows users to delete a category.</p>
  
  <pre class="lang-js prettyprint-override"><code>categoryRouter.delete('/:id', async (req, res) =&gt; {
    const { id } = req.params
    await req.context.models.Category.delete(id)
    return res.status(204).json()
  })
  </code></pre>
  
  <p>This route successfully deletes categories, but the problem is that related todo items are not getting their <code>category_id</code> property set to null, so they end up with a category id that no longer exists. Strangely though, if I open up my database GUI and manually execute the query to delete a category... <code>DELETE FROM category WHERE id=1</code>... the "ON DELETE SET NULL" hook is successfully firing. Any todo item that had <code>category_id=1</code> is now set to null.</p>
  
  <p>Full application source can be found <a href="https://github.com/johncmunson/todo-app" rel="nofollow noreferrer">here</a>.</p>