in reply to Re: DBIx::Class : stop changing table, column, relationship names
in thread DBIx::Class : stop changing table, column, relationship names
Thanks for your reply. Perhaps I was a bit vague, so here is some more detail.
No, the JSON data does not contain the relationships. Only table names, and I infer the foreign keys.
Consider the following SQL of two tables where one is referencing the other's PK:
CREATE TABLE MyappType ( Id INTEGER NOT NULL UNIQUE # ... ); CREATE TABLE AvailableMyapp ( MyappTypeId INTEGER NOT NULL, FOREIGN KEY(MyappTypeId) REFERENCES MyappType(Id) # ... );
Using:
DBIx::Class::Schema::Loader::make_schema_at( 'Myapps::Model::Schema', skip_load_external => 1, naming => { monikers => 'preserve', #relationships => 'current', column_accessors => 'preserve', }, );
creates following perl in file : Model::Schema::Result::AvailableMyapp
... __PACKAGE__->has_many( "available_myapps", "Myapps::Model::Schema::Result::AvailableMyapp", { "foreign.MyappTypeId" => "self.Id", }, { "cascade_copy" => "0", "cascade_delete" => "0", }, );
and this perl in file 'Model/Schema/Result/AvailableMyapp.pm':
... __PACKAGE__->belongs_to( "myapp_type", "Myapps::Model::Schema::Result::MyappType", { "Id" => "MyappTypeId", }, { "is_deferrable" => "0", "on_delete" => "NO ACTION", "on_update" => "NO ACTION", }, );
My problem is with the relationship names "available_myapps" and "myapp_type". I don't want the plural in the first one and I don't want to break the camel type for either.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: DBIx::Class : stop changing table, column, relationship names
by NERDVANA (Priest) on Mar 01, 2023 at 09:57 UTC | |
by bliako (Abbot) on Mar 03, 2023 at 08:39 UTC |