Created
November 21, 2016 13:55
-
-
Save simonamor/706cc2fcdca534e4ce332f1528eb8dfc to your computer and use it in GitHub Desktop.
->id created as accessor even though no id column - feature? bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| 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"; | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature. Defined in DBIx::Class::PK