adding a column on the fly

18 views
Skip to first unread message

François Rappaz

unread,
Aug 30, 2016, 7:57:25 AM8/30/16
to Rose::DB::Object
I have a table that is defined in Speak.pm as
    table   => 'speaks',

    columns => [
        speaksid  => { type => 'serial' },
        countryid => { type => 'integer', not_null => 1 },
        langid    => { type => 'integer', not_null => 1 },
    ],

    primary_key_columns => [ 'speaksid' ],

during a script I would like to have a new column langid1 that replicate the content of langid and that could be read with the usual get_langid1 method.

I tried
 my $data = Rdb::Speak::Manager->get_speaks(query => [countryid => {eq => $self->{countryid} }]);
my $meta = Rdb::Speak->meta;

$meta->alias_column(langid=>'langid1');
#or
$meta->add_nonpersistent_columns(langid=>{alias => 'langid1', methods =>[qw(get set)]});
fails when calling $row->langid1

#or
$meta->add_nonpersistent_columns(langid1=>{alias => 'langid', methods =>[qw(get set)]});
fails with No such column 'langid1' in table speaks
Thanks for any help

François
Reply all
Reply to author
Forward
0 new messages