[html-formfu] H::F::C::DBIC::Unique self_stash typos

Charlie Garrison garrison at zeta.org.au
Wed Oct 13 11:43:28 GMT 2010

Good evening,

On 9/09/10 at 3:30 PM +0100, Carl Franks <fireartist at gmail.com> wrote:

>On 9 September 2010 15:06, Tim Rayner <tfrayner at gmail.com> wrote:
>> That's fair enough. I guess the addition I'd really like to see is a
>> method allowing the user to specify more than one column to check
>> against, in cases where the database table has a compound unique key.
>> Charlie's "method_name" argument might well be a better way of doing
>> this, but in the attached example patch this method is called "others"
>> for the sake of argument. Alternatively it could be modified such that
>> the column method accepts an arrayref; I'm open to suggestions and/or
>> opinions. If this is already covered by a patch in the pipeline then
>> that's fine by me; the offer to work up a test suite still stands,
>> though, since I'd like to see this module released to CPAN so I don't
>> have to maintain a local fork.
>The use of 'others' is convenient, as the first column-name can be
>omitted, and it'll be automatically calculated from the field name.
>However, it may be easier to maintain you had to list all column-names
>in a single array-ref.
>I'm undecided, so we may as well go with the way you've done it,
>unless anyone else can think of any problems it might cause.
>I've committed both of these patches - thanks.
>If you're able to come up with even some basic tests, it can be
>included in the cpan release.

I've also made some changes to H::F::C::DBIC::Unique to allow 
calling a method (defined by method_name) on the resultset to 
determine uniqueness. The method is passed two arguments; the 
field value, and the PK value of the record on the stash (if 
any). The method should return true if the value is allowed 
(constraint passes) or false if the value is not allowed.

There are some tests included in the patch. The test files have 
an example method to show how it can be used, including checking 
against the record on the form stash. For me I need to compare 
the field value against a few tables to determine uniqueness. 
IOW, I needed to call a custom method.

Let me know if this patch is suitable or more tests are needed.


    Ꮚ Charlie Garrison ♊ <garrison at zeta.org.au>

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
〠  http://www.ietf.org/rfc/rfc1855.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: method_name.zip
Type: application/zip
Size: 2943 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/html-formfu/attachments/20101013/f1c70afc/method_name.zip

More information about the HTML-FormFu mailing list