add new set_serialize_column for DBIx::Class::Schema::Loader #1

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@fayland
fayland commented Dec 15, 2013

well, I'm using DBIx::Class::Schema::Loader to create those Result Tables.

which means I can't hack the add_columns to add the serializer_class

so instead, I add a new method to do that which I can do it after the md5sum

PACKAGE->load_components('InflateColumn::Serializer');
PACKAGE->set_serialize_column('data_column', 'JSON');

Thanks

@miquelruiz
Owner

Hi,

This functionality can be achieved using the add_columns with a plus sign prepending the column name, as stated in the ResultSource documentation:
https://metacpan.org/pod/DBIx::Class::ResultSource#add_columns

Following your example, you could use this snippet (after the md5sum) to set the JSON serializer for "data_column":

__PACKAGE__->add_columns(
  '+data_column',
  { serializer_class => 'JSON' }
);

Please, let us know if this works for you so we can close the issue :)

Regards,
Miquel Ruiz

@fayland
fayland commented Dec 28, 2013

Yes. works. thanks for the tip.

@fayland fayland closed this Dec 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment