Skip Menu |

This queue is for tickets about the DBIx-Class-Journal CPAN distribution.

Report information
The Basics
Id: 60983
Status: resolved
Priority: 0/
Queue: DBIx-Class-Journal

People
Owner: Nobody in particular
Requestors: OLIVER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.900200
Fixed in: (no value)



Subject: why is *_audit_log id col an auto-inc ?
In DBIx::Class::Schema::Journal::DB in journal_update_or_create_log_entry we use update_or_create but pass in a value for "id". This is contrary to the DBIx::Class documentation which says this should not be done for auto incrementing PK type columns. I actually think the mistake here is not that we pass a value for "id" but that "id" is configured as an auto-inc col in the table. What the value of this column contains is in fact the "id" of the row which has been created/deleted. For example given table username and username_audit_log, the "id" col of username_audit_log is a copy of the "id" of username. So should we remove the auto inc on the *_audit_log id? We should not set a FK constraint because the original row is potentially being deleted. Actually the FK could be "id" col of *_audit_history but there might be a race condition there, I'm not sure. Anyway, I thought I'd log this to see if anyone else is working on this code and whether they might have an opinion. I know that there aren't too many eyes on the Journal code normally :-} I also think we might do with better checking in journal_update_or_create_log_entry just in case the condition arises where a delete is logged without a corresponding previous create - this would fail because of the not null constraint on create_id. -- regards, oliver.
Subject: Re: [rt.cpan.org #60983] why is *_audit_log id col an auto-inc ?
Date: Thu, 2 Sep 2010 08:50:04 -0500
To: bug-DBIx-Class-Journal [...] rt.cpan.org
From: fREW Schmidt <frioux [...] gmail.com>
I agree that it's a mistake in the definition. It's clearly *not* an autoinc. In some databases setting an autoinc like that will give errors, so it's clearly wrong. As for the other checking, that sounds legit too. IIRC you already have commit to the repo, so feel free to make these changes and ping me and we'll cut another release. On Thu, Sep 2, 2010 at 6:56 AM, Oliver Gorwits via RT < bug-DBIx-Class-Journal@rt.cpan.org> wrote: Show quoted text
> Thu Sep 02 07:56:20 2010: Request 60983 was acted upon. > Transaction: Ticket created by OLIVER > Queue: DBIx-Class-Journal > Subject: why is *_audit_log id col an auto-inc ? > Broken in: 0.900200 > Severity: Unimportant > Owner: Nobody > Requestors: OLIVER@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=60983 > > > > > In DBIx::Class::Schema::Journal::DB in journal_update_or_create_log_entry > we use update_or_create but pass in a > value for "id". This is contrary to the DBIx::Class documentation which > says this should not be done for auto > incrementing PK type columns. > > I actually think the mistake here is not that we pass a value for "id" but > that "id" is configured as an auto-inc col > in the table. What the value of this column contains is in fact the "id" of > the row which has been created/deleted. > For example given table username and username_audit_log, the "id" col of > username_audit_log is a copy of the > "id" of username. > > So should we remove the auto inc on the *_audit_log id? We should not set a > FK constraint because the original > row is potentially being deleted. Actually the FK could be "id" col of > *_audit_history but there might be a race > condition there, I'm not sure. > > Anyway, I thought I'd log this to see if anyone else is working on this > code and whether they might have an > opinion. I know that there aren't too many eyes on the Journal code > normally :-} > > I also think we might do with better checking in > journal_update_or_create_log_entry just in case the condition > arises where a delete is logged without a corresponding previous create - > this would fail because of the not null > constraint on create_id. > > -- > regards, > oliver. >
-- fREW Schmidt http://blog.afoolishmanifesto.com
I think this is fixed correctly in commit 9763. I'll have some people look it over and then cut a release. As far as the extra validation mentioned, that's probably a good idea. I'll make a new RT for it later.
released (finally)