NAME

DBIO::InflateColumn::Serializer - Inflators to serialize data structures for DBIO

VERSION

version 0.900000

SYNOPSIS

package MySchema::Table;
use base 'DBIO::Core';

__PACKAGE__->load_components('InflateColumn::Serializer');
__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.

DESCRIPTION

These modules help you store and access serialized data structures in the columns of your DB from your DBIO classes. They provide inflators and deflators that serialize and deserialize data structures, with added protection:

  • throw an exception if the serialization doesn't fit in the field

  • throw an exception if the deserialization results in an error

The following serializer backends are included:

The backend modules are loaded on demand. You must install the required serialization module separately -- they are not hard dependencies of DBIO.

METHODS

register_column

Attach serializer-based inflate/deflate handlers for columns using serializer_class.

COLUMN INFO

serializer_class => $name

Selects the backend, e.g. JSON, YAML, MessagePack. The matching subclass under DBIO::InflateColumn::Serializer:: is loaded on demand.

USAGE NOTES

1. Install the serialization module you want to use (e.g. JSON::MaybeXS or YAML).

2. Add InflateColumn::Serializer to load_components in your Result class.

3. Add serializer_class => SERIALIZER to the column definition you want to serialize/deserialize.

Be careful not to overuse this capability. If you find yourself depending more and more on data inside an inflated column, factor it out into a real schema.

SEE ALSO

DBIO, DBIO::InflateColumn::Serializer::JSON, DBIO::InflateColumn::Serializer::YAML, DBIO::InflateColumn::Serializer::MessagePack

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.