Here is a patch that fixes this though it causes most of the unit tests to break because they don't respect foreign key reference using sqlite.
diff --git a/quantum/db/api.py b/quantum/db/api.py
index e10c7d4..0246a95 100644
--- a/quantum/db/api.py
+++ b/quantum/db/api.py
@@ -23,6 +23,7 @@ import time
import sqlalchemy as sql
from sqlalchemy import create_engine
from sqlalchemy.exc import DisconnectionError
+from sqlalchemy.interfaces import PoolListener
from sqlalchemy.orm import sessionmaker, exc
from quantum.db import model_base
@@ -56,6 +57,12 @@ class MySQLPingListener(object): raise
+class SqliteForeignKeysListener(PoolListener):
+ """Foreign keys are not enforced in sqlite unless specified."""
+ def connect(self, dbapi_con, con_record):
+ dbapi_con.execute('pragma foreign_keys=ON')
+
+
def configure_db(options):
"""
Establish the database, create an engine if needed, and
@@ -75,6 +82,9 @@ def configure_db(options):
if 'mysql' in connection_dict.drivername: engine_args['listeners'] = [MySQLPingListener()]
+ if 'sqlite' in connection_dict.drivername:
+ engine_args['listeners'] = [SqliteForeignKeysListener()]
+
_ENGINE = create_engine(options['sql_connection'], **engine_args)
base = options.get('base', BASE)
if not register_models(base):
Hi Jason,
Here is a patch that fixes this though it causes most of the unit tests to break because they don't respect foreign key reference using sqlite.
diff --git a/quantum/db/api.py b/quantum/db/api.py interfaces import PoolListener
index e10c7d4..0246a95 100644
--- a/quantum/db/api.py
+++ b/quantum/db/api.py
@@ -23,6 +23,7 @@ import time
import sqlalchemy as sql
from sqlalchemy import create_engine
from sqlalchemy.exc import DisconnectionError
+from sqlalchemy.
from sqlalchemy.orm import sessionmaker, exc
from quantum.db import model_base er(object) :
raise
@@ -56,6 +57,12 @@ class MySQLPingListen
+class SqliteForeignKe ysListener( PoolListener) : execute( 'pragma foreign_keys=ON') db(options) : db(options) : dict.drivername :
engine_ args['listeners '] = [MySQLPingListe ner()]
+ """Foreign keys are not enforced in sqlite unless specified."""
+ def connect(self, dbapi_con, con_record):
+ dbapi_con.
+
+
def configure_
"""
Establish the database, create an engine if needed, and
@@ -75,6 +82,9 @@ def configure_
if 'mysql' in connection_
+ if 'sqlite' in connection_ dict.drivername : args['listeners '] = [SqliteForeignK eysListener( )] engine( options[ 'sql_connection '], **engine_args) models( base):
+ engine_
+
_ENGINE = create_
base = options.get('base', BASE)
if not register_