mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
Enforce foreign keys on SQLite
This commit is contained in:
parent
4bbd7e94b0
commit
b57b086e04
@ -588,6 +588,7 @@ def init_database(database_uri):
|
||||
provider = "postgres"
|
||||
elif uri.scheme.startswith("sqlite"):
|
||||
provider = "sqlite"
|
||||
args["pragmas"] = {"foreign_keys": 1}
|
||||
else:
|
||||
raise RuntimeError(f"Unsupported database: {uri.scheme}")
|
||||
|
||||
|
@ -137,6 +137,7 @@ class AlbumSongsTestCase(ApiTestBase):
|
||||
)
|
||||
self.assertEqual(len(child), 0)
|
||||
|
||||
Track.delete().execute()
|
||||
Folder[1].delete_instance()
|
||||
rv, child = self._make_request(
|
||||
"getAlbumList", {"type": "random"}, tag="albumList"
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2017-2022 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2017-2023 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
@ -10,6 +10,7 @@ import unittest
|
||||
import uuid
|
||||
|
||||
from collections import namedtuple
|
||||
from peewee import IntegrityError
|
||||
|
||||
from supysonic import db
|
||||
|
||||
@ -20,11 +21,6 @@ class DbTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
db.init_database("sqlite:")
|
||||
|
||||
try:
|
||||
self.assertRegex
|
||||
except AttributeError:
|
||||
self.assertRegex = self.assertRegexpMatches
|
||||
|
||||
def tearDown(self):
|
||||
db.release_database()
|
||||
|
||||
@ -114,6 +110,10 @@ class DbTestCase(unittest.TestCase):
|
||||
|
||||
return playlist
|
||||
|
||||
def test_ensure_sqlite_foreign_keys(self):
|
||||
root, _, _ = self.create_some_folders()
|
||||
self.assertRaises(IntegrityError, root.delete_instance)
|
||||
|
||||
def test_folder_base(self):
|
||||
root_folder, child_folder, child_noart = self.create_some_folders()
|
||||
track_embededart = self.create_track_in(child_noart, root_folder)
|
||||
|
Loading…
Reference in New Issue
Block a user