From rp.neuli at yahoo.com Fri Mar 10 16:47:11 2017 From: rp.neuli at yahoo.com (Rajeev Prasad) Date: Fri, 10 Mar 2017 16:47:11 +0000 (UTC) Subject: [Dbix-class] Strangely does DBIx change table names from MySQL? References: <1939977130.2868556.1489164431235.ref@mail.yahoo.com> Message-ID: <1939977130.2868556.1489164431235@mail.yahoo.com> 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 | -------------- next part -------------- An HTML attachment was scrubbed... URL: From jorge.gonzalez at daikon.es Fri Mar 10 17:12:35 2017 From: jorge.gonzalez at daikon.es (Jorge Gonzalez) Date: Fri, 10 Mar 2017 18:12:35 +0100 Subject: [Dbix-class] Strangely does DBIx change table names from MySQL? In-Reply-To: <1939977130.2868556.1489164431235@mail.yahoo.com> References: <1939977130.2868556.1489164431235.ref@mail.yahoo.com> <1939977130.2868556.1489164431235@mail.yahoo.com> Message-ID: <6acec26e-0d58-4628-a840-d2847b932c3f.maildroid@localhost> 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 To: "DBIx::Class User and Developer List" , "dbi-users at perl.org" , Mysql Mailing List , "mysql-index at 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 | -------------- next part -------------- An HTML attachment was scrubbed... URL: From darren at darrenduncan.net Fri Mar 10 19:38:56 2017 From: darren at darrenduncan.net (Darren Duncan) Date: Fri, 10 Mar 2017 11:38:56 -0800 Subject: [Dbix-class] Strangely does DBIx change table names from MySQL? In-Reply-To: <6acec26e-0d58-4628-a840-d2847b932c3f.maildroid@localhost> References: <1939977130.2868556.1489164431235.ref@mail.yahoo.com> <1939977130.2868556.1489164431235@mail.yahoo.com> <6acec26e-0d58-4628-a840-d2847b932c3f.maildroid@localhost> Message-ID: On 2017-03-10 9:12 AM, Jorge Gonzalez wrote: > 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. Semantically this is one of those things I would argue that Entity Framework got (more) right and DBIC got (more) wrong. Semantically a table is a collection of rows where typically each row represents a singular entity, for example a single person, and a table represents a simple set/bag/array of those entities, and is collectively for example a group of 0..N people. I believe table-typed variables such as those in SQL databases should be named using the same naming conventions that are appropriate for arrays, after what the whole collection represents, such as "people", whereas row-typed variables would best be named for what a single row is, such as "person". As this simple example in SQL (like typical generated SQL) demonstrates: select person.name, person.age from people person Here "people" is the name of the table-typed SQL variable, and "person" is the name of the SQL range variable declared in the "select" that represents each individual row in turn. This is a loose Perl analogy: for my $person ($db->people) { print $person->name, $person->age } And so, DBIC would ideally name any classes/objects/variables representing a single person as Person while any representing a collection would be People, which is the behavior that "code first" Entity Framework defaults to. -- Darren Duncan From lasse at unity3d.com Fri Mar 10 22:20:17 2017 From: lasse at unity3d.com (Lasse Makholm) Date: Fri, 10 Mar 2017 23:20:17 +0100 Subject: [Dbix-class] Strangely does DBIx change table names from MySQL? In-Reply-To: References: <1939977130.2868556.1489164431235.ref@mail.yahoo.com> <1939977130.2868556.1489164431235@mail.yahoo.com> <6acec26e-0d58-4628-a840-d2847b932c3f.maildroid@localhost> Message-ID: On Fri, Mar 10, 2017 at 8:38 PM, Darren Duncan wrote: > On 2017-03-10 9:12 AM, Jorge Gonzalez wrote: > >> 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. >> > > Semantically this is one of those things I would argue that Entity > Framework got (more) right and DBIC got (more) wrong. > > Semantically a table is a collection of rows where typically each row > represents a singular entity, for example a single person, and a table > represents a simple set/bag/array of those entities, and is collectively > for example a group of 0..N people. > > I believe table-typed variables such as those in SQL databases should be > named using the same naming conventions that are appropriate for arrays, > after what the whole collection represents, such as "people", whereas > row-typed variables would best be named for what a single row is, such as > "person". > > As this simple example in SQL (like typical generated SQL) demonstrates: > > select person.name, person.age from people person > > Here "people" is the name of the table-typed SQL variable, and "person" is > the name of the SQL range variable declared in the "select" that represents > each individual row in turn. > > This is a loose Perl analogy: > > for my $person ($db->people) { print $person->name, $person->age } > That's sort of what DBIC does already: my $people = $db->resultset('Person')->search(...); foreach my $person ($people->all) { ... } And so, DBIC would ideally name any classes/objects/variables representing > a single person as Person while any representing a collection would be > People, which is the behavior that "code first" Entity Framework defaults > to. > The DBIC result source is named Person and each result (row) object is a Person. You should (in my opinion) read $db->resultset('Person') as "collection of objects of type Person". DBIC is nice in that way; it doesn't force you to remember when something is plural or singular - it's always singular. If you want to name your resultset $people, you are perfectly free to do so. > > -- Darren Duncan > > > _______________________________________________ > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class > IRC: irc.perl.org#dbix-class > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ > Searchable Archive: http://www.grokbase.com/group/ > dbix-class at lists.scsys.co.uk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lmh at intex.com Fri Mar 10 22:20:46 2017 From: lmh at intex.com (Larry Hochberg) Date: Fri, 10 Mar 2017 17:20:46 -0500 Subject: [Dbix-class] automated response Message-ID: <11703101720.AA210388386@mailserv.intex.com> I will be out of the office until March 24th. If you need immediate assistance please contact support at intex.com. Lawrence Hochberg