Tangra...torable(3pm)

πŸ“¦
version 2.12 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Tangra...torable(3pm) ✨

okay bestie so this is the user-contributed Perl documentation for the Tangra...torable(3pm) page, and it's literally all about dumping Perl stuff into your database and getting it back out again. no cap. πŸ’–


🌸 NAME 🌸

Tangram::Type::Dump::Storable β€” maps any Perl object as a scalar dump, all via Storable. it's giving "I don't need to know what's inside, I just need to yeet it into a column." πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

like, this is the vibe:

use Tangram::Core;
use Tangram::Type::Dump::Storable; # always

$schema = Tangram::Schema->new(
   classes => { NaturalPerson => { fields => {

   storable =>
   {
      diary => # diary is a perl hash
      {
         col => 'diarydata',
         sql => 'BLOB',
         indent => 0,
         terse => 1,
         purity => 0
      },

      lucky_numbers => 'int', # use defaults
   }
πŸ’… and yes, that # always comment is doing the lord's work β€” that module is a must, not a maybe.

πŸ’– DESCRIPTION πŸ’–

so what this actually does: it maps literally any arbitrary Perl data structure by serializing it into a string representation. the persistent fields get grouped together in a hash under the storable key inside the field hash. periodt.

the serialization itself is handled by Storable::freeze, which walks through your Perl data structure and builds a binary representation of it. that resulting string then gets mapped to the DBMS as a scalar value. and during restore? the scalar value gets restored with Storable::thaw to reconstruct the original data structure. it's a whole round trip, and honestly, obsessed. πŸ”₯

the structure should be able to hold pretty much anything that can be safely dumped by Storable. BUT β€” and this is the part where you listen to me β€” be aware that Tangram::Type::Dump::flatten() must be able to find the persistent objects in the field. unless you're using classes that are implemented in C and contain other objects, you should be fine. Set::Object has a special work-around. iykyk. πŸ™ˆ

the field names get passed in a hash that associates a field name with a field descriptor. and that field descriptor? it may be either a hash or a string, bestie. the hash uses these fields:

  • col
  • sql
  • indent
  • terse
  • purity

⭐ the col and sql situation ⭐

these two are optional: col and sql. they specify the column name and the column type for the scalar value in the database. lowkey important.

if they're not present, col defaults to the field name, and sql defaults to VARCHAR(255). πŸ’œ

and heads up β€” values will always be quoted as they are passed to the database. no exceptions, no arguments.


🧚 the serialization options 🧚

the remaining optional fields are the ones controlling the serialization process. they get passed down to Data::Dumper as values to the corresponding Data::Dumper options. iconic handoff honestly.

the default settings are:

  • no indentation (indent=0)
  • compact format (terse=1)
  • quick dump (purity=0)

slay. πŸ“


πŸ‘‘ AUTHOR πŸ‘‘

this mapping was contributed by Gabor Herr <herr@iti.informatik.tu-darmstadt.de> β€” thank you for your service, legend. 🫢


🌈 SEE ALSO 🌈

hmm bestie, this one's a little shy β€” there aren't any SEE ALSO references on this page. no crumbs, no cross-links. just vibes. πŸ’€


and that's the whole page, fr fr. ✨ this cutie was brought to you by perl v5.36.0, dated 2022-10-16, and it's the user-contributed Perl documentation for Tangra...torable(3pm). take care of her πŸŒΈπŸ’…πŸŽ€

πŸ“¦ where this page comes from