in reply to DBIx::Class : stop changing table, column, relationship names
If you have relationships defined in JSON, then why are you using Schema::Loader? You could just generate the DBIC result classes however you like. If you want to pick up the database column names, but define custom relationships, you can do that by putting the relationships below the auto-generated code, and Schema::Loader will preserve all that custom code while re-generating the column definitions.
There is one project where I wanted to retroactively use SchemaLoader, but other developers had already chosen all sorts of names for the relationships, and I needed to preserve that. I ended up writing a very long rel_name_map parameter in my script that runs Schema::Loader to override all its choices of relationship name. i.e.
and so on for ~50 relationships or so. It was annoying and tedious, but let me choose all the specific names I needed to preserve. I don't recommend this really; since you have them in JSON already you could just tell Schema::Loader to ignore foreign keys and then inject the relationships into the generated code yourself with option filter_generated_code.rel_name_map => { Group => { reportnum => 'report', rpt_sections => 'sections', },
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBIx::Class : stop changing table, column, relationship names
by bliako (Abbot) on Feb 28, 2023 at 18:36 UTC | |
by NERDVANA (Priest) on Mar 01, 2023 at 09:57 UTC | |
by bliako (Abbot) on Mar 03, 2023 at 08:39 UTC |