[CDBI] problem with no primary key?

[prev] [thread] [next] [Date index for 2005/11/25]

From: Tilman Baumann
Subject: [CDBI] problem with no primary key?
Date: 19:00 on 25 Nov 2005
Hello,

i have a little problem with Class::DBI.
I think its because one of my tables has no primary key.

I have this two tables:

CREATE TABLE "option"
(
product_id varchar(20) NOT NULL,
name varchar(30) NOT NULL,
value int8 DEFAULT 0,
CONSTRAINT option_product_id_fkey FOREIGN KEY (product_id) REFERENCES
product (id) ON UPDATE CASCADE ON DELETE CASCADE
)
WITHOUT OIDS;

CREATE TABLE product
(
id varchar(20) NOT NULL,
"type" varchar,
description text,
arcode varchar(20),
license_id varchar(20),
created date,
activated date,
duration interval,
activationkey varchar(32),
"class" varchar,
CONSTRAINT product_pkey PRIMARY KEY (id)
)
WITHOUT OIDS;


option sould be a collection of name > values for a product.
So Product has_many Options.

Here is the Code:
package LicServ::Product;
use base 'LicServ::DBI';
LicServ::Product->table('product');
LicServ::Product->columns(All =3D> qw(id activated created type class
description duration arcode license_id activationkey));
LicServ::Product->has_a(license_id =3D> 'LicServ::License');
LicServ::Product->has_many(options =3D> 'LicServ::Option');

package LicServ::Option;
use base 'LicServ::DBI';
LicServ::Option->table('option');
LicServ::Option->columns(Key =3D> qw(name product_id value));
LicServ::Option->has_a(product_id =3D> 'LicServ::Product');


I get
-----------
LicServ::Option can't SELECT
FROM option
WHERE product_id =3D ?
: DBD::Pg::st execute failed: FEHLER: Fehler =EF=BF=BDSyntaxfehler=EF=BF=BD=
 bei =EF=BF=BDFROM=EF=BF=BD
at character 9
[for Statement "SELECT
FROM option
WHERE product_id =3D ?
" with ParamValues: 1=3D'CBS-1'] at
/usr/share/perl5/DBIx/ContextualFetch.pm line 52.
at /usr/share/perl5/Class/DBI/Relationship/HasMany.pm line 118
-----------
on a foreach my $option ($product->options)

FEHLER: Fehler =EF=BF=BDSyntaxfehler=EF=BF=BD bei =EF=BF=BDFROM=EF=BF=BD =
at character 9 -> in English is
ERROR: Error Syntaxerror near FROM at character 9
Strangely Postgres has a german locale. I thought is was running as root
ans so should have none... Howerver. :)

If i type SELECT * FROM option WHERE product_id =3D 'CBS-1' i get the
correct anser. So i think the problem is that no SELECT _what_ is given.


Any idea how to avoid this problem?

Tank you all

--=20
Tilman Baumann
Software Developer
Collax GmbH . Boetzinger Stra=C3=9Fe 60 . 79111 Freiburg . Germany

p: +49 (0) 761-4514-836
f: +49 (0) 761-4563-793



_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

[CDBI] problem with no primary key?
Tilman Baumann 19:00 on 25 Nov 2005

Re: [CDBI] problem with no primary key?
Matt S Trout 19:25 on 25 Nov 2005

Re: [CDBI] problem with no primary key?
Tilman Baumann 19:18 on 25 Nov 2005

Generated at 14:51 on 01 Dec 2005 by mariachi v0.52