Reputation: 1371
I'm using DBIx::Class::Schema::Loader to create a schema like this:
#!/usr/bin/perl
use strict;
use warnings;
use DBIx::Class::Schema::Loader qw/make_schema_at/;
make_schema_at(
"Mydb::Schema",
{debug => 0, dump_directory => "../db/",
generate_pod => 0,},
["dbi:mysql:mydb:localhost:3306", 'mydb', 'password'],
);
My table name in MySQL is people
, but when I run this code, the generated class is named Mydb::Schema::Result::Person
:
$ cat Mydb/Schema/Result/Person.pm
use utf8;
package Mydb::Schema::Result::Person;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table("people");
__PACKAGE__->add_columns(
"pplid",
{
data_type => "smallint",
extra => { unsigned => 1 },
is_auto_increment => 1,
is_nullable => 0,
},
...
...
Why is "people" being converted to "Person"?
Upvotes: 2
Views: 361
Reputation: 24073
By default, DBIx::Class::Schema::Loader singularizes the names of Result classes. It makes sense to have a database table of people, but it doesn't make sense to have an object representing a single person called "People".
If you really want, you can change this by setting the naming
option in make_schema_at
:
make_schema_at(
"Mydb::Schema",
{
debug => 0,
dump_directory => "../db/",
generate_pod => 0,
naming => { monikers => 'preserve' }
},
["dbi:mysql:mydb:localhost:3306", 'mydb', 'password'],
);
But I would recommend sticking with the defaults.
Upvotes: 5