Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
0fb1f285
Commit
0fb1f285
authored
Feb 23, 2018
by
Hugo Beauzée-Luyssen
Browse files
Label: Split triggers creation in a specific method
parent
32d07824
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Label.cpp
View file @
0fb1f285
...
...
@@ -92,14 +92,19 @@ void Label::createTable( sqlite::Connection* dbConnection )
"PRIMARY KEY (label_id, media_id),"
"FOREIGN KEY(label_id) REFERENCES Label(id_label) ON DELETE CASCADE,"
"FOREIGN KEY(media_id) REFERENCES Media(id_media) ON DELETE CASCADE);"
;
sqlite
::
Tools
::
executeRequest
(
dbConnection
,
req
);
sqlite
::
Tools
::
executeRequest
(
dbConnection
,
relReq
);
}
void
Label
::
createTriggers
(
sqlite
::
Connection
*
dbConnection
)
{
const
std
::
string
ftsTrigger
=
"CREATE TRIGGER IF NOT EXISTS delete_label_fts "
"BEFORE DELETE ON "
+
policy
::
LabelTable
::
Name
+
" BEGIN"
" UPDATE "
+
policy
::
MediaTable
::
Name
+
"Fts SET labels = TRIM(REPLACE(labels, old.name, ''))"
" WHERE labels MATCH old.name;"
" END"
;
sqlite
::
Tools
::
executeRequest
(
dbConnection
,
req
);
sqlite
::
Tools
::
executeRequest
(
dbConnection
,
relReq
);
sqlite
::
Tools
::
executeRequest
(
dbConnection
,
ftsTrigger
);
}
...
...
src/Label.h
View file @
0fb1f285
...
...
@@ -58,6 +58,7 @@ class Label : public ILabel, public DatabaseHelpers<Label, policy::LabelTable>
static
LabelPtr
create
(
MediaLibraryPtr
ml
,
const
std
::
string
&
name
);
static
void
createTable
(
sqlite
::
Connection
*
dbConnection
);
static
void
createTriggers
(
sqlite
::
Connection
*
dbConnection
);
private:
MediaLibraryPtr
m_ml
;
...
...
src/MediaLibrary.cpp
View file @
0fb1f285
...
...
@@ -171,6 +171,7 @@ void MediaLibrary::createAllTriggers()
Genre
::
createTriggers
(
m_dbConnection
.
get
()
);
Playlist
::
createTriggers
(
m_dbConnection
.
get
()
);
History
::
createTriggers
(
m_dbConnection
.
get
()
);
Label
::
createTriggers
(
m_dbConnection
.
get
()
);
}
template
<
typename
T
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment