|
From: Gert T. <th...@ba...> - 2002-08-14 10:37:10
|
Sorry,
but the SPOPS documentation is *very* incomplete.
1) Multiple-Field ID Fields
I declared as follows:
'articleprices' =3D> {
'object_name' =3D> 'articleprice',
'class' =3D> 'BaerShopSF::data::articleprices',
'isa' =3D> [ qw/ SPOPS::DBI::MySQL SPOPS::DBI / ],
'rules_from' =3D> [ qw/ SPOPS::Tool::DBI::Datasource=20
SPOPS::Tool::DBI::DiscoverField SPOPS::Tool::ReadOnly / ],
'base_table' =3D> 'ARTIKEL_VKPREIS',
'field_discover' =3D> 'yes',
'id_field' =3D> [ 'ARTIKEL', 'LAND', 'WAEHRUNG' ],
'increment_field' =3D> 'no',
'dbi_config' =3D> {
dsn =3D> $r->dir_config('ShopSF_DbA_S=
'),
username =3D> $r->dir_config('ShopSF_DbA_U=
'),
password =3D> $r->dir_config('ShopSF_DbA_P=
'),
},
'track' =3D> { create =3D> 1, update =3D> 1, delete =3D=
> 1 },
},
nevertheless this fails:
$articlespecialprice =3D BaerShopSF::data::articlespecialprices->fetc=
h( [$a,=20
$country, $currency] );
Why? Can you give some examples?
2) Relationships (has_a, links_to)
How do has_a and links_to work?
Can you give some examples?
Gert.
|
|
From: Chris W. <ch...@cw...> - 2002-08-14 11:55:57
|
On Wed, 2002-08-14 at 06:39, Gert Thiel wrote:
> Sorry,
>
> but the SPOPS documentation is *very* incomplete.
Well, on this feature it is :-)
> 1) Multiple-Field ID Fields
>
> I declared as follows:
>
> 'articleprices' => {
> 'object_name' => 'articleprice',
> ...
> 'id_field' => [ 'ARTIKEL', 'LAND', 'WAEHRUNG' ],
This is correct.
> nevertheless this fails:
>
> $articlespecialprice = BaerShopSF::data::articlespecialprices->fetch( [$a,
> $country, $currency] );
Instead of being an arrayref, you specify the ID in a comma-separated
string:
$articlespecialprice = BaerShopSF::data::articlespecialprices->fetch(
"$a,$country,$currency" );
You can look at t/31_dbi_multifield.t for more examples. I'm adding
documentation to SPOPS::DBI right now.
> Why? Can you give some examples?
>
> 2) Relationships (has_a, links_to)
>
> How do has_a and links_to work?
> Can you give some examples?
For 'links_to', please see 'perldoc SPOPS::ClassFactory::DBI'.
For 'has_a'... wow, there's nothing there. My apologies.
There are working examples of relationships in the eg/ directory:
My::Doodad has_a My::User, My::User links_to My::Group, My::Group
links_to My::User.
I'll move the existing examples for 'links_to' and add new information
for 'has_a' to SPOPS::Manual::Relationships so they're in one place.
Thanks for bringing these up.
Chris
--
Chris Winters (ch...@cw...)
Building enterprise-capable snack solutions since 1988.
|
|
From: Gert T. <th...@ba...> - 2002-08-14 12:16:12
|
Thanks, but, > Instead of being an arrayref, you specify the ID in a comma-separated > string: > > $articlespecialprice =3D BaerShopSF::data::articlespecialprices->fetch= ( > "$a,$country,$currency" ); that helped. But your manual says "As of SPOPS 0.53, SPOPS::DBI supports multi-field primary keys. To use i= t,=20 you just use an arrayref to represent the ID field rather than a string.=20 (Wisenheimers who use an arrayref with one element may be shocked that SP= OPS=20 finds this attempt to trick it and sets the value to the single element.)= " Please don't mind, but that's weird. > You can look at t/31_dbi_multifield.t for more examples. I'm adding > documentation to SPOPS::DBI right now. > > > Why? Can you give some examples? > > > > 2) Relationships (has_a, links_to) > > > > How do has_a and links_to work? > > Can you give some examples? > > For 'links_to', please see 'perldoc SPOPS::ClassFactory::DBI'. > > For 'has_a'... wow, there's nothing there. My apologies. > > There are working examples of relationships in the eg/ directory: > My::Doodad has_a My::User, My::User links_to My::Group, My::Group > links_to My::User. Will lokk there asap. > I'll move the existing examples for 'links_to' and add new information > for 'has_a' to SPOPS::Manual::Relationships so they're in one place. Good idea. SPOPS is a very powerful piece of software. But as such it is as usable a= s=20 it's documentation complete :-( > Thanks for bringing these up. Thank you. Gert. |
|
From: Chris W. <ch...@cw...> - 2002-08-14 12:23:33
|
On Wed, 2002-08-14 at 08:18, Gert Thiel wrote: > that helped. But your manual says > > "As of SPOPS 0.53, SPOPS::DBI supports multi-field primary keys. To use it, > you just use an arrayref to represent the ID field rather than a string. > (Wisenheimers who use an arrayref with one element may be shocked that SPOPS > finds this attempt to trick it and sets the value to the single element.)" > > Please don't mind, but that's weird. You're absolutely right. I'll fix that. (My memory's not so good as more grey hairs pop out from my head :-) > SPOPS is a very powerful piece of software. But as such it is as usable as > it's documentation complete :-( I agree. That's why I really appreciate you bringing up holes in the documentation. It's very easy for me to forget what I've done in the past. Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |
|
From: Chris W. <ch...@cw...> - 2002-08-15 13:02:28
|
On Wed, 2002-08-14 at 08:18, Gert Thiel wrote: > SPOPS is a very powerful piece of software. But as such it is as usable as > it's documentation complete :-( For the relationship information, see: http://www.cwinters.com/raw/Relationships.pod This is after a day or so and I need to go through and edit some more, but it should be mostly there. Let me know what you think. Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |
|
From: Gert T. <th...@ba...> - 2002-08-15 14:50:39
|
Chris, nice to read your addition to the docs. This is tough stuff so I can't comment every details at once. But I found= a=20 flaw: You say has_a forms a "one-to-one" relationship. From a objects point of = view=20 is right. But with RDBMS terms it is not. If you objects like this: publisher book has_a publisher it is a one-to-one as there is only one publisher per book but there are = books=20 for any publisher. You should explain that details because SPOPS is used as a oo wrapper aro= und a=20 RDMS. Their users could you probs to understand you. More later. Gert. |
|
From: Chris W. <ch...@cw...> - 2002-08-16 12:29:39
|
On Thu, 2002-08-15 at 10:53, Gert Thiel wrote: > You say has_a forms a "one-to-one" relationship. From a objects point of view > is right. But with RDBMS terms it is not. > > If you objects like this: > publisher > book has_a publisher > > it is a one-to-one as there is only one publisher per book but there are books > for any publisher. > > You should explain that details because SPOPS is used as a oo wrapper around a > RDMS. Their users could you probs to understand you. Good point. I'll change this. Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |