Tangra...p::Perl(3pm)

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

✨ Tangram::Type::Dump::Perl ✨

okay bestie, pull up a chair 🫢 this is the Tangram::Type::Dump::Perl page from the User Contributed Perl Documentation, and it's literally about mapping any Perl object as a scalar dump. yes, any. no cap.


🌸 NAME 🌸

Tangram::Type::Dump::Perl β€” map any Perl object as scalar dump πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

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

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

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

      lucky_numbers => 'int', # use defaults
   }
⚠️ note the # always next to that use β€” yeah, this one's not optional, she's mandatory ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

So what does she do? She maps arbitrary Perl data structures by serializing them into a string representation. Iconic behavior honestly. 😌

The persistent fields get grouped into a hash under the perl_dump key in the field hash. That's the vibe.

Serialization is handled by Data::Dumper β€” she traverses the Perl data structure and builds a string representation out of it. That resulting string then gets mapped to the DBMS as a scalar value. And during restore? The scalar value gets eval'd to reconstruct the original data structure. the way that it round-trips… obsessed πŸ’–

As of Tangram 2.07.1, persistent references are safely handled via the Tangram::Type::Dump utility class. safe!! handled!! we love to see it 🫢

The field names are passed in a hash that associates a field name with a field descriptor. The field descriptor can be either a hash or a string. The hash uses the following fields:

  • col
  • sql
  • indent
  • terse
  • purity

🌈 the optional bits 🌈

The optional fields col and sql specify the column name and the column type for the scalar value in the database. If they're not present, col defaults to the field name, and sql defaults to VARCHAR(255). And bestie, values will always be quoted as they are passed to the database β€” no exceptions, periodt. πŸ’…

The remaining optional fields control the serialization process. They get passed down to Data::Dumper as values for the corresponding Data::Dumper options. Default settings are:

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

like… defaults are giving low-effort-but-correct and honestly? valid πŸŽ€


πŸ‘‘ AUTHOR πŸ‘‘

This mapping was contributed by Gabor Herr <herr@iti.informatik.tu-darmstadt.de> β€” thank you for your service, king πŸ«‘πŸ’œ


and that's the page, bestie!! this was perl v5.36.0, dated 2022-10-16, from the Tangra...p::Perl(3pm) manual πŸ’– go serialize something unhinged, ily, bye!! βœ¨πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from