[mythtv-commits] Ticket #2040: Initialize categoryID in Metadata
MythTV
mythtv at cvs.mythtv.org
Mon Jul 10 00:20:43 UTC 2006
#2040: Initialize categoryID in Metadata
----------------------------------------------+-----------------------------
Reporter: sphery <mtdean at thirdcontact.com> | Owner: awithers
Type: patch | Status: new
Priority: minor | Milestone:
Component: mythvideo | Version:
Severity: medium |
----------------------------------------------+-----------------------------
Trivial patch initializes the categoryID in !MythVideo's Metadata.
Without the patch, using the Edit Metadata screen often results in
placement of invalid ID's in the category field of the metadata table--
even where a valid value previously existed (due to the use of the copy
constructor in EditMetadataDialog's constructor, which is required to
allow abandoning of changes). Since the Metadata's getCategoryID()
function only calls lookupCategoryID() if categoryID <= 0, it often fails
to lookup a categoryID even when we have a valid category name (depending
on the uninitialized value of categoryID). In this case, the UI shows the
value "Unknown", but a value equal to the uninitialized value of
categoryID will be written to the database if the user saves the data.
It's also theoretically possible that the uninitialized value may be a
valid ID for a category, which will result in changing the user's category
to something other than Unknown.
This also fixes the problem noted on the lists that categories are often
made invalid by doing IMDB lookups ( http://www.gossamer-
threads.com/lists/mythtv/users/190838#190838 ) (I know. I'm about a
month and a half late on the fix :).
I set the categoryID to 0 in the copy constructor even though it's
probably valid in the original object. Doing so allows for changes to the
table "behind the scenes." This seems to be the approach that was desired
by the original author (since the copy constructor did not previously copy
the categoryID field) and only results in one extra query to the database
per copied Metadata object. Copying the original object's categoryID
should work, as well.
Also attached is a patch that "fixes" the invalid category ID's (
mythplugins-mythvideo-initialize_categoryid-dbcheck.patch ) in the
database. It does this by simply changing invalid category ID's to 0,
which results in the user seeing the value "Unknown" for the category
(which they would see even with the invalid value). Although the
dbcheck.cpp patch is not absolutely required, I feel it's prudent to
remove invalid data from the database. The patch uses a LEFT JOIN instead
of a subquery, so it should work on all supported versions of MySQL.
For those applying this patch to working copies, I recommend not applying
the mythplugins-mythvideo-initialize_categoryid-dbcheck.patch patch and--
if concerned about the invalid data--instead running the SQL below. Then,
if the dbcheck patch is applied to the main distro, it will result in no
changes to the metadata (since your data will be valid), but will allow
you to maintain a VideoDBSchemaVer that's in sync with head (in case the
patch isn't applied).
{{{
UPDATE videometadata
LEFT JOIN videocategory ON (videometadata.category = videocategory.intid)
SET videometadata.category = 0
WHERE videocategory.intid IS NULL;
}}}
--
Ticket URL: <http://svn.mythtv.org/trac/ticket/2040>
MythTV <http://www.mythtv.org/>
MythTV
More information about the mythtv-commits
mailing list