I'm new to Perl and DBIx::Class.
This is how I get my meaning_ids
from the table translation where language = 5:
my $translations = $schema -> resultset('Translation')->search({ language => '5'});
After it I'm trying to push my data from the database into my array data:
while ( my $translation =$translations->next ) {
push @{ $data }, {
meaning_id => $translation-> meaning
};
}
$self->body(encode_json $data );
If I do it like this, I get the following error:
encountered object 'TranslationDB::Schema::Result::Language=HASH(0x9707158)', but neither allow_blessed , convert_blessed nor allow_tags settings are enabled (or TO_JSON/FREEZE method missing)
But if I do it like that:
while ( my $translation =$translations->next ) {
push @{ $data }, {
meaning_id => 0+ $translation-> meaning
};
}
$self->body(encode_json $data );
I don't get the error anymore, but the meaning is not the number out of the database. It's way too big (something like 17789000
, but only numbers till 7000
are valid).
Is there an easy way to tell Perl that meaning_id
is an INT and not a string?