[html-formfu] different behavior of H::F::Model::DBIC 0.04002 and
0.04003
Moritz Onken
onken at houseofdesign.de
Thu May 28 13:34:01 GMT 2009
Glad it worked four you!
I bumped the prerequisite DBIC to 0.081 in the Makefile.PL
Is this ok with you, Carl?
Am 27.05.2009 um 16:16 schrieb Mike South:
> On Wed, May 27, 2009 at 6:09 AM, Moritz Onken
> <onken at houseofdesign.de> wrote:
>> I probably need the hole cat app.
>> Do you have the latest DBIC installed?
>
> No, I didn't. I had 0.08012. And I put in the latest, and
>
> IT WORKS!
>
> Thanks!
>
> The reason seems to be that the attrs is now aware of this being a
> foreign key relationship:
>
> My debugging output:
>
> here is the info$VAR1 = {
> 'cond' => {
> 'foreign.company_id' => 'self.company_id'
> },
> 'source' => 'TWST::Editorial::DB::Company',
> 'attrs' => {
> 'is_foreign_key_constraint' => 1,
> 'undef_on_null_fk' => 1,
> 'accessor' => 'filter'
> },
> 'class' => 'TWST::Editorial::DB::Company'
> };
>
> You might want to add a minimum version to the DBIC that
> H::F::M::DBIC requires.
>
> THANK YOU for working through this with me, and for all your hard work
> on this stuff!
>
> mike
>>
>>
>> Am 27.05.2009 um 06:48 schrieb Mike South:
>>
>>> Also, it's the Select element for the user_id, if that's any help.
>>>
>>> mike
>>>
>>> On Tue, May 26, 2009 at 11:38 PM, Mike South <msouth at gmail.com>
>>> wrote:
>>>>
>>>> It happens on post. I think the data gets saved, but the render
>>>> that
>>>> happens after that fails.
>>>>
>>>> I am in the debugger, looking at a case that is about to puke,
>>>> and the
>>>> $info variable contains:
>>>>
>>>> DB<15> x $info
>>>> 0 HASH(0x4c71e38)
>>>> 'attrs' => HASH(0x4c718c8)
>>>> 'accessor' => 'filter'
>>>> 'class' => 'TWST::Editorial::DB::User'
>>>> 'cond' => HASH(0x4c71d60)
>>>> 'foreign.user_id' => 'self.user_id'
>>>> 'source' => 'TWST::Editorial::DB::User'
>>>>
>>>> I am a DBIC newbie, but my database does actually have columns
>>>> named
>>>> user_id in the "user" table and the "article" table. (btw I don't
>>>> create databases like this, I inherited this one.) The foreign key
>>>> relationship is article.user_id = user.user_id.
>>>>
>>>> I can send you my whole catalyst app if you want, but maybe you can
>>>> get enough information out of the following:
>>>>
>>>> elsif ( defined $multi_value ) {
>>>> # belongs_to, has_one or might_have relationship
>>>>
>>>> my $info = $dbic->result_source->relationship_info($rel);
>>>> (see dump above)
>>>> my @fpkey =
>>>> $dbic->related_resultset($rel)->result_source->primary_columns;
>>>>
>>>> DB<31> x $dbic->related_resultset($rel)->result_source-
>>>> >primary_columns;
>>>> 0 'user_id'
>>>>
>>>> my @cond = (%{$info->{cond}});
>>>>
>>>> DB<32> x @cond
>>>> 0 'foreign.user_id'
>>>> 1 'self.user_id'
>>>>
>>>> # make sure $rel is a has_one or might_have rel
>>>> # stolen from SQL/Translator/Parser/DBIx/Class
>>>>
>>>> my $fk_constraint;
>>>>
>>>> # Get the key information, mapping off the foreign/self
>>>> markers
>>>> my @refkeys = map {/^\w+\.(\w+)$/} @cond;
>>>>
>>>> is the refkeys array used?
>>>> DB<33> x @refkeys
>>>> 0 'user_id'
>>>> 1 'user_id'
>>>>
>>>>
>>>> my @keys = map { $info->{cond}{$_} =~ /^\w+\.(\w+)$/ }
>>>> grep { exists $info->{cond}{$_} }
>>>> @cond;
>>>> DB<37> x map { $info->{cond}{$_} =~ /^\w+\.(\w+)$/ } grep
>>>> { exists
>>>> $info->{cond}{$_} } @cond;
>>>> 0 'user_id'
>>>>
>>>> #first it can be specified explicitly
>>>> if ( exists $info->{attrs}{is_foreign_key_constraint} ) {
>>>> $fk_constraint = $info->{attrs}
>>>> {is_foreign_key_constraint};
>>>> }
>>>>
>>>> x exists $info->{attrs}{is_foreign_key_constraint}
>>>> 0 ''
>>>>
>>>>
>>>> # it can not be multi
>>>> elsif ( $info->{attrs}{accessor}
>>>> && $info->{attrs}{accessor} eq 'multi' ) {
>>>> $fk_constraint = 0;
>>>> }
>>>> DB<39> x $info->{attrs}{accessor}
>>>> 0 'filter'
>>>>
>>>> # if indeed single, check if all self.columns are our
>>>> primary
>>>> keys.
>>>> # this is supposed to indicate a has_one/might_have...
>>>> # where's the introspection!!?? :)
>>>> else {
>>>> $fk_constraint = not
>>>> $dbic->result_source->compare_relationship_keys( \@keys, \@fpkey );
>>>> }
>>>>
>>>> $dbic->result_source->compare_relationship_keys( \@keys, \@fpkey );
>>>>
>>>> is only checking to see if everything in \@keys is in \@fpkey, and
>>>> vice-versa--that is, if they are the same array, possibly
>>>> rearranged.
>>>> Which is true in this case, because the two lists just contain
>>>> 'user_id'.
>>>>
>>>>
>>>>
>>>> next if($fk_constraint);
>>>>
>>>> $fk_constraint was set by the not $dbic->res.... above, to the
>>>> empty
>>>> string.
>>>>
>>>> #FIXME
>>>> $DB::single=1;
>>>> my $fpkey = shift @fpkey;
>>>> 'user_id'
>>>> my ( $fkey, $skey ) = @cond;
>>>> 'foreign.user_id', 'self.user_id'
>>>> $fkey =~ s/^foreign\.//;
>>>> $skey =~ s/^self\.//;
>>>> now they are both 'user_id'
>>>> my $fclass = $info->{class};
>>>>
>>>> and croak
>>>> croak $VERSION.': The primary key and the foreign key may
>>>> not be the same column in class '.$fclass
>>>> if $fpkey eq $fkey;
>>>>
>>>> Is that enough to go on? Or do you want my whole app? Or do you
>>>> want
>>>> me to try to make a smaller reproduction?
>>>>
>>>> mike
>>>>
>>>>
>>>>
>>>> On Tue, May 26, 2009 at 2:35 PM, Moritz Onken <onken at houseofdesign.de
>>>> >
>>>> wrote:
>>>>>
>>>>> Hi Mike,
>>>>>
>>>>> I'm sorry but couldn't simulate the error you described. Can you
>>>>> provide
>>>>> a
>>>>> running example which fails with that error? No need for a
>>>>> catalyst app,
>>>>> just a perl script which populates the form (see
>>>>> t/update/belongs_to_select.t for an example).
>>>>>
>>>>> cheers,
>>>>>
>>>>> moritz
>>>>>
>>>>> Am 26.05.2009 um 20:21 schrieb Mike South:
>>>>>
>>>>>> On Tue, May 26, 2009 at 12:34 PM, Moritz Onken <onken at houseofdesign.de
>>>>>> >
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> can you provide the dbic classes?
>>>>>>
>>>>>> Attached.
>>>>>>
>>>>>>> Did you try Model::DBIC 0.05 which just shipped to the cpan?
>>>>>>
>>>>>> Yes. I altered it to put $VERSION in front of the message:
>>>>>>
>>>>>> Caught exception in TWST::Editorial::Controller::Article->edit
>>>>>> "0.05:
>>>>>> The primary key and the foreign key may not be the same column in
>>>>>> class TWST::Editorial::DB::User at
>>>>>> /home/msouth/code/EPS/script/../lib/TWST/Editorial/Controller/
>>>>>> Base.pm
>>>>>> line 96
>>>>>>
>>>>>> mike
>>>>>>
>>>>>>>
>>>>>>> cheers,
>>>>>>>
>>>>>>> moritz
>>>>>>>
>>>>>>>
>>>>>>> Am 26.05.2009 um 15:05 schrieb Mike South:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> the list rejected my email, not sure why. I tried applying
>>>>>>>> the patch
>>>>>>>> and still got the same problem that the other poster
>>>>>>>> mentioned. I
>>>>>>>> will provide you any details you need, just let me know what
>>>>>>>> you need
>>>>>>>> to see.
>>>>>>>>
>>>>>>>> mike
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------- Forwarded message ----------
>>>>>>>> From: <html-formfu-owner at lists.scsys.co.uk>
>>>>>>>> Date: Tue, May 26, 2009 at 7:57 AM
>>>>>>>> Subject: Re: [html-formfu] different behavior of
>>>>>>>> H::F::Model::DBIC
>>>>>>>> 0.04002 and 0.04003
>>>>>>>> To: msouth at gmail.com
>>>>>>>>
>>>>>>>>
>>>>>>>> You are not allowed to post to this mailing list, and your
>>>>>>>> message
>>>>>>>> has
>>>>>>>> been automatically rejected. If you think that your messages
>>>>>>>> are
>>>>>>>> being rejected in error, contact the mailing list owner at
>>>>>>>> html-formfu-owner at lists.scsys.co.uk.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------- Forwarded message ----------
>>>>>>>> From: Mike South <msouth at gmail.com>
>>>>>>>> To: "HTML Form Creation, Rendering and Validation Framework"
>>>>>>>> <html-formfu at lists.scsys.co.uk>
>>>>>>>> Date: Tue, 26 May 2009 07:57:44 -0500
>>>>>>>> Subject: Re: [html-formfu] different behavior of
>>>>>>>> H::F::Model::DBIC
>>>>>>>> 0.04002 and 0.04003
>>>>>>>> On Wed, May 13, 2009 at 6:02 AM, Moritz Onken
>>>>>>>> <onken at houseofdesign.de>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> My bad. I'm very sorry.
>>>>>>>>>
>>>>>>>>> Applied is a patch for DBIC and a test which addresses this
>>>>>>>>> issue,
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I applied that patch and I still get the error. I'm trying
>>>>>>>> to update
>>>>>>>> my 'interviewee' table, which has a foreign key to my 'article'
>>>>>>>> table,
>>>>>>>> and the error message says "The primary key and the foreign
>>>>>>>> key may
>>>>>>>> not be the same column in class Foo::Bar::DB::Article".
>>>>>>>>
>>>>>>>> Let me know what information about you need about my setup.
>>>>>>>>
>>>>>>>> mike
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Sorry again.
>>>>>>>>>
>>>>>>>>> cheers,
>>>>>>>>>
>>>>>>>>> moritz
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Am 13.05.2009 um 09:13 schrieb Wolfgang Kinkeldei:
>>>>>>>>>
>>>>>>>>>> Good morning,
>>>>>>>>>>
>>>>>>>>>> the 2 latest versions of HTML::FormFu::Model::DBIC do behave
>>>>>>>>>> differently.
>>>>>>>>>>
>>>>>>>>>> In my table 'product' I have a column 'color_id' that
>>>>>>>>>> references
>>>>>>>>>> color(color_id).
>>>>>>>>>>
>>>>>>>>>> the relevant part of my form config for a product looks
>>>>>>>>>> like this:
>>>>>>>>>> <snip>
>>>>>>>>>> - type: Select
>>>>>>>>>> name: color_id
>>>>>>>>>> label: Color
>>>>>>>>>> empty_first: 1
>>>>>>>>>> empty_first_label: '- none -'
>>>>>>>>>> model_config:
>>>>>>>>>> resultset: Color
>>>>>>>>>> label_column: color_name
>>>>>>>>>> attributes:
>>>>>>>>>> order_by: color_name
>>>>>>>>>> <snap>
>>>>>>>>>>
>>>>>>>>>> Updating a record with 0.04002 works fine, doing the same
>>>>>>>>>> with
>>>>>>>>>> 0.04003
>>>>>>>>>> yields the message:
>>>>>>>>>> 'The primary key and the foreign key may not be the same
>>>>>>>>>> column in
>>>>>>>>>> class
>>>>>>>>>> ...'
>>>>>>>>>>
>>>>>>>>>> Am I doing something wrong that changed and I missed it?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Regards,
>>>>>>>>>>
>>>>>>>>>> Wolfgang Kinkeldei
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> ' /\_/\ ' .print[split??,"".(($/=q|Cms)+-03467:;<=|)=~tr!C-
>>>>>>>>>> z -B!
>>>>>>>>>> -z!)x
>>>>>>>>>> '( o.o )' .$/]->[hex]foreach split
>>>>>>>>>> qr<>,qq+1ecd039ad65b025b8063475b+||
>>>>>>>>>> ' > ^ < ' .q<!-- Wolfgang Kinkeldei -
>>>>>>>>>> mailto:wolfgang at kinkeldei.de -->
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> HTML-FormFu mailing list
>>>>>>>>>> HTML-FormFu at lists.scsys.co.uk
>>>>>>>>>> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> HTML-FormFu mailing list
>>>>>>>>> HTML-FormFu at lists.scsys.co.uk
>>>>>>>>> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> <fkey_problem.tgz>
>>>>>
>>>>>
>>>>
>>
>>
More information about the HTML-FormFu
mailing list