Tangra...:Scalar(3pm)
β¨ NAME β¨
Tangram::Type::Scalar β bestie, this is the page that maps scalar fields π
(it's the Tangra...:Scalar(3pm) manual, if you're keeping track π)
πΈ SYNOPSIS πΈ
Okay so picture this, you're setting up your schema and it goes a lil something like:
use Tangram;
Tangram::Schema->new(
classes => { NaturalPerson => { fields => {
string => [ qw( name firstName gender ) ],
int => [ qw( age ) ],
real => [ qw( height weight ) ],
$schema = Tangram::Schema->new(
classes => { NaturalPerson => { fields => {
string =>
{
name => { sql => 'VARCHAR(100)' },
1stname => {
col => 'firstName',
sql => 'VARCHAR(100) NULL' },
gender => undef()
},
(and yes, that's exactly how it looks, no I did not clean it up, the vibes are the vibes π)
π¦ DESCRIPTION π¦
So the classes Tangram::Type::String, ::Int, ::Real and ::Ref are the ones responsible for mapping all the different subtypes of scalars β¨. The first three mappings β String, Int, Real β get documented right here on this page, because lowkey they differ very very little from each other π«Ά. And if you wanna know about mapping references? Head over to Tangram::Type::Ref::FromMany, that's its whole moment π
Tangram::Type::String uses DBI's quote() method to quote strings if that method is available β which is iconic of it, honestly, because that means you can store binary objects or multiline text in databases that support it π₯. (Big thanks to Marian Kelc <marian.kelc@ruhr-uni-bochum.de> for suggesting this improvement, we love a contributor moment π)
The three predefined typetags are "string", "int" and "real", and they're for the corresponding Perl scalar subtypes. Periodt.
Each scalar field gets stored in a single column of the table that's associated to the class. One field, one column, no complications, we love that for us π
The persistent fields can be specified either as a hash or as an array of field names. Both are valid, pick your fighter π
π Hash form π
When you go the hash route, each entry is a field name plus an associated option hash. That option hash may contain the following fields:
colsqlautomatic
Let's break those down bestie:
colβ sets the name of the column used to store the field's value. This one's optional, it defaults to the persistent field name. Override it if your field name is not an acceptable SQL column name π«sqlβ sets the SQL type of the column. It's used bySchema::deploy()when initializing a database. The defaults are:'VARCHAR(255) NULL'for strings,'INT NULL'for ints, and'REAL NULL'for reals β¨automaticβ if you set this to true, it tells Tangram not to save the field to storage. Super useful for auto-increment or timestamp columns, iykyk π
π§ Array form π§
You can also specify the persistent fields as an array of strings β and in that case, the defaults are used. Simple as that, no notes π
and that's the whole page, bestie, you ate it π β this was Tangra...:Scalar(3pm) from perl v5.36.0, dated 2022-10-16, so yeah, it's giving vintage but it still slays π
β¨
π¦ 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