On Fri, 7 Oct 2011, [email protected] wrote: > i'm new using DBIx::Class.
I was also very recently. After figuring it out it is very pleasant apart from a couple of oddities. > First question : why my table named regles (with a ending 's') > gives me a pm file Regle.pm (without ending 's') ? I got bitten by this also. It is doing some magic with English language. I got around of this simply by sticking with table names which do not end with "s". There is probably some proper way to tell DBIx::Class that it should NOT make an assumption that the table names are in English, but I have not found it in documentation yet. Maybe someone else can give further details on this? Also it names some relations with added "s" in the end. So if I have a one-to-many relation to table "sukat", the name of the relation becomes "sukats" even though "sukat" is already in plural. I do not know French, but the magic certainly does not work with Finnish by default. You can avoid all of this by defining your Schemas manually (i.e. just dump them once, remove the "DO NOT EDIT" comments, format the files nicely and name your classes, tables, columns and relations how you like). It seems more reliable that way (you can create your tables with "deploy" method based on the Perl class definitions). > And i got the error: > > DBIx::Class::Schema::resultset(): Can't find source for Regle at > ogs-import.pl line 15 > > any help? regards Your "use" statements do not match with the package names in the files. Compare below. In ogs-import.pl you have: > use lib::OGS2::Schema; But in Schema.pm you have: > package OGS2::Schema; You should write instead: use lib 'lib'; use OGS2::Schema; The same thing with the other "use": > use lib::OGS2::Schema::Result::Regle; But in Regle.pm the "s" logic has bitten you also: > package OGS2::Schema::Result::Regles; You should change the name of the file to Regles.pm and the "use" line to match that: use OGS2::Schema::Result::Regles; ...although actually you do not need that at all, because in Schema.pm you have: > __PACKAGE__->load_namespaces; ...which loads the Schema classes from the sub-directories already. You still need to make all of them match: "Regles" or "Regle" but not a mixture of both. Just avoid the "s" at the end and you will be fine (until someone gives a proper answer :). -- Janne Snabb / EPIPE Communications [email protected] - http://epipe.com/ _______________________________________________ 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/[email protected]
