DBIC by default follows the convention that table names reflect the entity name 
in singular. If It detects table names in plural It uses a Lingua::* module to 
deduce the apropriate singular name, and names the clases with It.

In your case, the table names IS "people", but the generated class name IS 
"Person", the singular for people.

Admittedly yours IS a bit of an extreme case :-)

This behaviour can be changed, see the docs for DBIC::Schema::Loader and search 
for an option named like "*inflect*" or something similar (I'm on my cellphone 
and can't search at the moment :-)

BR
J.

-- 
Jorge González Villalonga
Ingeniero de Sistemas / Systems Engineer
Red Hat Certified Engineer #140-183-666
Móvil / Cell: (+34) 672 173 200

-----Original Message-----
From: Rajeev Prasad <rp.ne...@yahoo.com>
To: "DBIx::Class User and Developer List" <dbix-cl...@lists.scsys.co.uk>, 
"dbi-users@perl.org" <dbi-users@perl.org>, Mysql Mailing List 
<my...@lists.mysql.com>, "mysql-in...@lists.mysql.com" 
<mysql-in...@lists.mysql.com>
Sent: vie., 10 mar. 2017 17:49
Subject: [Dbix-class] Strangely does DBIx change table names from MySQL?

Hello,
Note: this question is also posted on Stack Overflow, a few minutes back.
  
| 
 | While using ./create-schema-mydb.pl I realized that the table name "People" 
is changed to "Person" in DBIx. I am not sure how? or why?
It is not even a reserved word.

in MySQL:people innoDB utf8

create-schema script:$ cat ./create-schema-mydb.pl
#!/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'],
);


It shows up like this after create-schema... note the change in name from 
People to Person, but inside the .pm file table name is retained as People !!!
Result$ cat 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,
  },
...
...

only relevant portion shown above...


Thank you.

Rajeev
  |

Reply via email to