How can I prevent DBIx :: Class :: Schema :: Loader from automatically adding InflateColumn :: DateTime to Catalyst?

I use Catalyst and DBIx :: Class :: Schema :: Loader to create my model in Catalyst as follows:

script/myapp_create.pl model DB DBIC::Schema MyApp::Schema create=static overwrite_modifications=1 components=EncodedColumn dbi:mysql:mydb mydb pass 

Unfortunately, the bootloader automatically sets InflateColumn::DateTime as the default component, which I don't want. I want to get the original value from the database.

 __PACKAGE__->load_components("InflateColumn::DateTime", "EncodedColumn"); 

Can someone tell me how to prevent this?

+6
perl dbix-class catalyst
source share
1 answer

Man, this is annoying. It seems that it is impossible to get what you want as it is.

_build_loader_components in Catalyst :: Helper :: Model :: DBIC :: Schema adds it, if you do not have namespaces and there is no result namespace, It clicks on your additional component= list.

 my @components = $self->old_schema && (not $use_namespaces) ? () : ('InflateColumn::DateTime'); 

So the options are

It should be what you wanted -

 dbicdump -o dump_directory=./lib \ -o components='["EncodedColumn"]' \ -o use_namespaces=1 \ -o overwrite_modifications=1 \ MyApp::Schema dbi:mysql:foo user pass 

And then just a simple model for its wrapper -

 script/myapp_create.pl model DB DBIC::Schema MyApp::Schema 

Update: preserve_case came out, since your example did not use it, and Id would like to mention for best practice that the password should not be in the model or schema classes. It should be in config, and if you are using something that allows this, like mysql, it should be configured to read from a configuration file that is specific to certain privileges.

+6
source share

All Articles