Tangra...p::Any(3pm)
π Tangram::Type::Dump::Any β the whole vibe π
okay bestie, so this is Tangra...p::Any(3pm) β a User Contributed Perl Documentation page, and honestly? it's giving chaos in the best way. it's called Tangram::Type::Dump::Any, and the official sub-title is "Intuitive DataBase InterFace" β yes, lowercase I, capital DBIF, iconic. let's get into it π«Ά
β¨ SYNOPSIS β¨
so like, imagine you're in a nearby Tangram::Schema structure (that's literally what the original says, "in a nearby Tangram::Schema structure", slay) and you write this:
# ... in a nearby Tangram::Schema structure ...
SomeClass =>
{ fields =>
{ idbif => {
-options => { dumper => 'Data::Dumper',
},
some_field => undef,
some_property => undef,
some_attribute => undef,
each_one => undef,
gets => undef,
saved => undef,
},
string => {
cheese => undef,
},
},
};
look at those undefs. they're just vibing. no thoughts, head empty, undef. π
πΈ DESCRIPTION πΈ
okay so the idbif mapping type is the main character here, and what it does is collate multiple data members into a single column. that single column can be one of three flavours:
- a
perl_dumpcolumn (peepTangram::Type::Dump::Perl) - a
storablecolumn (peepTangram::Type::Dump::Storable) - a
yamlcolumn (peepTangram::Type::Dump::YAML)
and fr fr, using the schema definition from the example above, all the columns in that example would be serialised via Data::Dumper. every single one. no cap.
so say you stored an object like this:
$cheese = bless { cheese => "gouda",
gets => 6,
each_one => 9 }, "SomeClass";
then in your database you'd see something similar to:
/^'--v------v--------v----------------------------'^\
| id | type | cheese | idbif |
>----o------o--------o------------------------------<
| 1 | 42 | gouda | { gets => 6, each_one => 9 } |
\_,--^------^--------^----------------------------._/
look at that ASCII art. it ate. π
little note from the original, bestie: the actual output from your SQL Database client may differ from the above. don't come for me, blame your client.
so if you're the type of person who likes to set their attributes with accessors but does NOT like the overhead this places on the RDBMSβ¦ then this may help. and here's the tea: the original says Note β the real benefits of this mapping type are for when you're storing more complex data structures than "6" and "9" :-). like, imagine. 6 and 9 are cute but they're not the moment.
oh and btw, you may prefer to use the default dumping type, which is storable. just saying. β¨
π LINKS TO OTHER OBJECTS π
so if Tangram runs into another object that's already in storage (meaning it's been inserted via $storage->insert($foo)), then it will store a "Memento". and this memento includes the object ID β which is sensitive to schema changes, specifically the ordering of classes in the schema. so don't be out here reordering your classes like it's a playlist, okay? π
but if the class implements a "px_freeze" and "px_thaw" function, then there will be a "Memento" that includes the class name of the object, plus the data that was returned by the class' "px_freeze" method. and to be reconstituted, it gets called like this:
SomeClass->px_thaw(@data)
if you wanna know more about the complicity API (yes, complicity, that's the actual word, i'm not making this up π), go check Tangram::Type::Dump.
β οΈ please set RETVAL to be the thawed object. that is, return a single scalar. one. uno. fr fr. π
π BUT, I REALLY, REALLY HATE SCHEMAS! π
okay so maybe you're one of those folk who don't like to declare their attributes, and instead you're just out here peppering hashes willy nilly. if that's you, bestie, there's another option. π
instead of explicitly listing the fields you want: if you don't specify any fields at all, then it means save ALL remaining fields into the column. for convenience, -poof is provided as a synonym for -options, so you can write:
{ fields =>
{ idbif => { -poof => # There goes another one!
{
},
}
},
}
<- -poof, it vanishes, it's giving magic trick πͺβ¨
and now for the author's note, which i am legally required to pass along in full because it's an absolute serve:
[ You see, Tangram::Type::Dump::Any isn't actually an intuitive DB interface. No, an intuitive DB interface is a user interface component, and that title is reserved for Visual Tangram. VT expects to pick up the title with any luck by the end of the 21st century^W RSN! I Don't Believe In Fairies is actually what it stands for. It's a completely arbitrary name; chosen for no reason at all, and certainly not anything to do with Pixie. ]
the ^W is a backspace, bestie β they typed RSN over the top of "21st century" and left it in. that's the rawest form of editing and i respect it deeply. π
and that's the page!! tysm for reading, you're doing amazing sweetie π«Ά this was Tangram::Type::Dump::Any from perl v5.36.0, dated 2022-10-16 β go forth and dump your data members, mwah πβ¨
π¦ where this page comes from
- ubuntu noble: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtangram-perl 2.12-4 Β· 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