DBIx::...alizer(3pm)
β¨ NAME β¨
DBIx::Class::InflateColumn::Serializer β inflators that serialize your data structures for DBIx::Class π (this one lives in the User Contributed Perl Documentation section of the manual, bestie, and yes it's a 3pm page π)
πΈ SYNOPSIS πΈ
okay so first you set up your table class like this:
package MySchema::Table;
use base 'DBIx::Class';
__PACKAGE__->load_components('InflateColumn::Serializer', 'Core');
__PACKAGE__->add_columns(
'data_column' => {
'data_type' => 'VARCHAR',
'size' => 255,
'serializer_class' => 'JSON'
}
);
Then in your code... β¨
my $struct = { 'I' => { 'am' => 'a struct' };
$obj->data_column($struct);
$obj->update;
And you can recover your data structure with:
my $obj = ...->find(...);
my $struct = $obj->data_column;
The data structures you assign to data_column will be saved in the database in JSON format. no cap π«Ά
π DESCRIPTION π
These modules help you store and access serialized data structures in the columns of your DB from your DBIx::Classes. They are inspired from the DBIx::Class::Manual::FAQ and the DBIC test suite, and provide a bit more protection than the inflators proposed in the FAQ. The intention is to provide a suite of well proven and reusable inflators and deflators to complement DBIx::Class.
Added features for these inflators are:
- throw an exception if the serialization doesn't fit in the field π
- throw an exception if the deserialization results in an error π
Right now there are three serializers:
StorableJSONYAML
π¦ USAGE π¦
- Choose your serializer:
JSON,YAMLorStorableβ pick your fighter, they're all iconic π - Add
'InflateColumn::Serializer'into theload_componentsof your table class - add
'serializer_class' => SERIALIZERto the properties of the column that you want to (de/i)nflate with the SERIALIZER class.
π NOTES π
As stated in the DBIC FAQ: "Be careful not to overuse this capability, however. If you find yourself depending more and more on some data within the inflated column, then it may be time to factor that data out."
fr fr bestie, this is a vibe check on your schema design, not just a warning π
π AUTHOR π
Jose Luis Martinez
CPAN ID: JLMARTIN
CAPSiDE
jlmartinez@capside.com
http://www.pplusdomain.net
π COPYRIGHT π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
π THANKS π
Matt S Trout for his valuable feedback
Ask Bjorn Hansen
Karen Etheridge
β SEE ALSO β
DBIx::Class, DBIx::Class::Manual::FAQ
and that's the whole page, bestie π«Ά this was DBIx::...alizer(3pm) from perl v5.40.1, dated 2026-05-07 β go forth and inflate responsibly π
β¨
π¦ where this page comes from
- ubuntu stonking: libdbix-class-inflatecolumn-serializer-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms