Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Complete code (schemas etc) with unambiguous field names:
#!/usr/bin/perl use lib qw(lib); use DBIC::Schema; use Data::Dumper; my $schema = DBIC::Schema->connect("dbi:Pg:dbname=dbic; host=localhost +","pguser","pgpassword"); my $t1_rs = $schema->resultset('T1'); $query_rs = $t1_rs->search; while (my $account = $query_rs->next) # LOOK HERE! { print Dumper $account->fieldwith->name; } # DOES NOT WORK WITH print Dumper $account->fieldwiths->name; # METHOD HAS NO *S* IN IT my $t2_rs = $schema->resultset('T2'); $query_rs = $t2_rs->search; while (my $account = $query_rs->next) { print Dumper $account->fieldwithout->name; } __DATA__ CREATE DATABASE dbic WITH OWNER = pguser ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' CONNECTION LIMIT = -1; GRANT ALL ON DATABASE ng TO postgres; REVOKE CONNECT ON DATABASE pguser FROM PUBLIC; GRANT CONNECT ON DATABASE ng TO pguser; \c dbic CREATE TABLE r1 ( id integer, name character varying(64), PRIMARY KEY (id) ) WITH ( OIDS=TRUE ); ALTER TABLE r1 OWNER TO pguser; CREATE TABLE t1 ( id integer, fieldwiths integer REFERENCES r1(id), PRIMARY KEY (id) ) WITH ( OIDS=TRUE ); ALTER TABLE t1 OWNER TO pguser; CREATE TABLE r2 ( id integer, name character varying(64), PRIMARY KEY (id) ) WITH ( OIDS=TRUE ); ALTER TABLE r2 OWNER TO pguser; CREATE TABLE t2 ( id integer, fieldwithout integer REFERENCES r2(id), PRIMARY KEY (id) ) WITH ( OIDS=TRUE ); ALTER TABLE t2 OWNER TO pguser; REVOKE CONNECT ON DATABASE dbic FROM PUBLIC; GRANT CONNECT ON DATABASE dbic TO pguser; REVOKE ALL ON ALL TABLES IN SCHEMA public FROM PUBLIC; GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO pguser; dbicdump -o dump_directory=./lib \ -o components='["InflateColumn::DateTime"]' \ -o debug=1 \ DBIC::Schema \ 'dbi:Pg:dbname=dbic; host=localhost' \ pguser \ pgpassword delete from t1; delete from r1; insert into r1(id, name) values (1, 'Alpha'); insert into r1(id, name) values (2, 'Bravo'); insert into r1(id, name) values (3, 'Charlie'); insert into t1(id, fieldwiths) values(1, 1); insert into t1(id, fieldwiths) values(2, 2); insert into t1(id, fieldwiths) values(3, 3); delete from t2; delete from r2; insert into r2(id, name) values ('1', 'Alpha'); insert into r2(id, name) values ('2', 'Bravo'); insert into r2(id, name) values ('3', 'Charlie'); insert into t2(id, fieldwithout) values(1, '1'); insert into t2(id, fieldwithout) values(2, '2'); insert into t2(id, fieldwithout) values(3, '3');


Greetz
Beatnik
... I'm belgian but I don't play one on TV.

In reply to Re: DBI::Class relationship naming by Beatnik
in thread DBI::Class relationship naming by Beatnik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2021-12-09 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (36 votes). Check out past polls.

    Notices?