Skip to content

Instantly share code, notes, and snippets.

@simonamor
Created November 21, 2016 13:55
Show Gist options
  • Select an option

  • Save simonamor/706cc2fcdca534e4ce332f1528eb8dfc to your computer and use it in GitHub Desktop.

Select an option

Save simonamor/706cc2fcdca534e4ce332f1528eb8dfc to your computer and use it in GitHub Desktop.
->id created as accessor even though no id column - feature? bug?
{
package SomeResult;
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table("foo");
__PACKAGE__->add_columns(
foo_id => {
data_type => "integer",
is_auto_increment => 1
},
name => {
data_type => "char",
is_nullable => 1
},
);
__PACKAGE__->set_primary_key("foo_id");
}
{
package SomeSchema;
use base "DBIx::Class::Schema";
__PACKAGE__->register_class( SomeResult => "SomeResult" );
}
my $s = SomeSchema->connect("DBI:SQLite:dbname=:memory:");
$s->deploy;
my $obj = $s->resultset("SomeResult")->create({ name => "Simon" });
print "foo_id: " . $obj->foo_id . "\n";
print " id: " . $obj->id . "\n";
@simonamor
Copy link
Author

Feature. Defined in DBIx::Class::PK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment