diff options
author | Yorhel <git@yorhel.nl> | 2015-10-21 02:19:15 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2015-10-21 02:28:48 +0200 |
commit | 9cf3eef0e0a7bde10a0e1bb8c94c38b058e5121d (patch) | |
tree | 9cbd3a439316bdfe3946cc80378e4f95a9d6e6db /lib/VNDB/DB/Staff.pm | |
parent | 718f4d0258049aa92f229c08d5ec7204dae3ffa6 (diff) |
SQL: Fix editing + func.sql + triggers.sql + autocreate editing funcs
This changes quite a bit to the way the editing functions work. Because
these functions are very repetitive and it's easy to keep things out of
sync, I created a script to generate them automatically. I had to rename
a few function and table names for consistency to make this work.
Since database entries don't have a 'latest' column anymore, and since
the order in which tables are updated doesn't have to be fixed, I
dropped many of the SQL triggers and replaced them with a
edit_committed() function which is called from edit_*_commit() and
checks for stuff to be done.
Don't forget to run 'make' before importing the update script.
Diffstat (limited to 'lib/VNDB/DB/Staff.pm')
-rw-r--r-- | lib/VNDB/DB/Staff.pm | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/VNDB/DB/Staff.pm b/lib/VNDB/DB/Staff.pm index 8c6badd6..fb472c72 100644 --- a/lib/VNDB/DB/Staff.pm +++ b/lib/VNDB/DB/Staff.pm @@ -152,15 +152,15 @@ sub _enrich { sub dbStaffRevisionInsert { my($self, $o) = @_; - $self->dbExec('DELETE FROM edit_staff_aliases'); + $self->dbExec('DELETE FROM edit_staff_alias'); if($o->{aid}) { $self->dbExec(q| - INSERT INTO edit_staff_aliases (id, name, original) VALUES (?, ?, ?)|, + INSERT INTO edit_staff_alias (aid, name, original) VALUES (?, ?, ?)|, $o->{aid}, $o->{name}, $o->{original}); } else { $o->{aid} = $self->dbRow(q| - INSERT INTO edit_staff_aliases (name, original) VALUES (?, ?) RETURNING id|, - $o->{name}, $o->{original})->{id}; + INSERT INTO edit_staff_alias (name, original) VALUES (?, ?) RETURNING aid|, + $o->{name}, $o->{original})->{aid}; } my %staff = map exists($o->{$_}) ? (qq|"$_" = ?|, $o->{$_}) : (), @@ -168,9 +168,9 @@ sub dbStaffRevisionInsert { $self->dbExec('UPDATE edit_staff !H', \%staff) if %staff; for my $a (@{$o->{aliases}}) { if($a->{aid}) { - $self->dbExec('INSERT INTO edit_staff_aliases (id, name, original) VALUES (!l)', [ @{$a}{qw|aid name orig|} ]); + $self->dbExec('INSERT INTO edit_staff_alias (aid, name, original) VALUES (!l)', [ @{$a}{qw|aid name orig|} ]); } else { - $self->dbExec('INSERT INTO edit_staff_aliases (name, original) VALUES (?, ?)', $a->{name}, $a->{orig}); + $self->dbExec('INSERT INTO edit_staff_alias (name, original) VALUES (?, ?)', $a->{name}, $a->{orig}); } } } @@ -183,7 +183,7 @@ sub dbStaffAliasIds { SELECT DISTINCT sa.aid FROM changes c JOIN staff_alias_hist sa ON sa.chid = c.id - WHERE c.type = \'s\' AND c.itemid = ?|, $sid); + WHERE c.type = 's' AND c.itemid = ?|, $sid); } 1; |