[Pdx-pm] DBIC "Can't find source" error
Joshua Keroes
joshua at keroes.com
Wed Apr 21 18:12:41 PDT 2010
Test code's working now. The trick was that DBIC wasn't autopopulating the
FK in the related table. I had to do that on my own:
use Integra::UBI::Schema;
my $schema =
Integra::UBI::Schema->connect("dbi:mysql:ubi:water.integra.engr","ubi","F1ng3r!");
my $row = $schema->resultset('ECCKT')->create({
'ecckt' => 'ABCD0123456ABCDEF',
});
$row->create_related(
interfaces => {
'ecckt_id' => $row->ecckt_id, # not auto-populated
'customer' => 'John Johnsonson',
'end' => 1269644794,
'interface' => 'GigabitEthernet10/1',
'router' => 'ar11.slkcutxd.example.com',
'speed' => 1000000000,
'start' => 1265958902,
'state' => 'active',
}
);
$row->update;
Is there a DBIC way to call create() just once and have it populate both
tables simulaneously? With both
ecckt.ecckt_id = interfaces.ecckt_id and ecckt.if_id = interfaces.if_id ?
Cheers,
Joshua
On Wed, Apr 21, 2010 at 6:04 PM, Joshua Keroes <joshua at keroes.com> wrote:
> More silliness; these two commands should be the same (--upgrade and -u are
> synonyms). They're returning different results.
>
> jkeroes at jkeroes ~/svn/modules/Integra-UBI-Schema [1233]
> % dbicadmin --schema=Integra::UBI::Schema
> --connect='["dbi:mysql:ubi:water.integra.engr","ubi","pass"]' -u -q .
> Performig action update...
> DBIx::Class::Admin::update(): resultset() expects a source name at
> /opt/local/bin/dbicadmin line 72
>
> jkeroes at jkeroes ~/svn/modules/Integra-UBI-Schema [1234:255]
> % dbicadmin --schema=Integra::UBI::Schema
> --connect='["dbi:mysql:ubi:water.integra.engr","ubi","pass"]' --upgrade -q .
> Performig action upgrade...
> DBIx::Class::Admin::upgrade(): Upgrade not necessary
>
>
> On Wed, Apr 21, 2010 at 5:19 PM, Joshua Keroes <joshua at keroes.com> wrote:
>
>> On Wed, Apr 21, 2010 at 5:11 PM, Robert Buels <rmb32 at cornell.edu> wrote:
>>
>>> I don't get that error using that code.
>>>
>>> Are all your modules in different files? load_namespaces is actually
>>> based on .pm files on disk, not just package names.
>>>
>>
>> Separate files:
>>
>> jkeroes at water:~/svn/modules/Integra-UBI-Schema
>> [Thu Apr 22, 00:18:21 | 526] $ tree
>> .
>> ├── lib/
>> │ └── Integra/
>> │ └── UBI/
>> │ ├── Schema/
>> │ │ └── Result/
>> │ │ ├── ECCKT.pm
>> │ │ └── Interface.pm
>> │ └── Schema.pm
>> ├── t/
>> │ ├── 00-load.t
>> │ ├── boilerplate.t
>> │ ├── pod-coverage.t
>> │ └── pod.t
>> ├── .cvsignore
>> ├── Changes
>> ├── MANIFEST
>> ├── Makefile.PL
>> └── README
>>
>> 6 directories, 12 files
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/pdx-pm-list/attachments/20100421/c816c41b/attachment.html>
More information about the Pdx-pm-list
mailing list