LittleJack has asked for the wisdom of the Perl Monks concerning the following question:
I don't know if I'm misunderstanding something fundamental here, but here's the situation:
I have a module: package Model::DB::Result::Thing; and it looks basically like this:
and Model::DB is justpackage Model::DB::Result::Thing; use warnings; use base 'DBIx::Class::Core'; __PACKAGE__->table("table_in_postgres"); __PACKAGE__->add_columns( "id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0, sequence => "things_id_seq", }, "some_thing", { data_type => "text", is_nullable => 0, }, );
package Model::DB; use strict; use warnings; use base 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces; 1;
All the other parts of my codebase (a legacy Catalyst App) seem happy with it, and I can do some things with it which show that it's connecting to the DB correctly, see below.
What I can't do it seems is get a simple set of results back with all() or search()
What I'm expecting, as per this page https://metacpan.org/release/RIBASUSHI/DBIx-Class-0.082841/view/lib/DBIx/Class/ResultSet.pm is that I do my $thing_rs = $c->model('DB::Thing')->all(); but when I do that and use Data::Dumper I get an integer, the number of rows: $VAR1 = 123;
So I try calling in list context: my @thing_rs = $c->model('DB::Thing')->all(); and I get $VAR1 as the whole MyApp::Model::DB::Thing object, followed by 123 blessed objects like this:
$VAR2 = bless( { '_result_source' => $VAR1->{'_result_source'}, '_in_storage' => 1, '_column_data' => { 'some_thing' => 'foo', 'id' => 99, } }, 'MyApp::Model::DB::Thing' );
What I'm expecting is an array of hashes containing what I see there in the blessed objects, i.e.
[ { 'some_thing' => 'foo', 'id' => 99, }, { 'some_thing' => 'bar', 'id' => 100, }, # etc ]
So I'm kind of stumped. Is something different because it's PostGres? Is my version of DBIxC (0.082840) weird? TIA Monks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Issues with DBIx::Class
by Your Mother (Archbishop) on Mar 23, 2022 at 04:40 UTC | |
|
Re: Issues with DBIx::Class
by 1nickt (Canon) on Mar 23, 2022 at 17:56 UTC | |
by NERDVANA (Priest) on Mar 24, 2022 at 02:25 UTC | |
by LittleJack (Beadle) on Mar 24, 2022 at 00:37 UTC | |
by 1nickt (Canon) on Mar 24, 2022 at 11:28 UTC | |
by LittleJack (Beadle) on Mar 25, 2022 at 03:26 UTC | |
|
Re: Issues with DBIx::Class
by NERDVANA (Priest) on Mar 24, 2022 at 02:38 UTC |