Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: SQL function from DBIC

by f00li5h (Chaplain)
on Dec 07, 2008 at 16:32 UTC ( #728737=note: print w/replies, xml ) Need Help??

in reply to SQL function from DBIC

This one time, on #dbix-class, mst told me somet things about virtual views with DBIC.

package MySchema::Sneaky; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/Core/); __PACKAGE__->table("DUMMY"); # madness going on # scalar ref to the sql statement __PACKAGE__->result_source_instance->name( \<<EOSQL); ( select foo, bar from baz ) EOSQL __PACKAGE__->add_columns( qw/ foo bar / );

Note that SQL::Translator will have trouble ->deploying this kind of table, and you need a hook to remove this table from the definition with something like:

package MySchema; use strict; use base qw/DBIx::Class::Schema/; sub sqlt_deploy_hook { my ($self, $sqlt_schema) = @_; my @pesky_tables = grep /^SCALAR\(0x[0-9A-F]+\)/i, keys %{ $sqlt_s +chema->{tables} }; $sqlt_schema->drop_table( $_ ) for @pesky_tables; local $" = ', '; warn "Removed @pesky_tables from list of tables t +o deploy"; use Data::Dumper; #die Dumper $sqlt_schema; }

@_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://728737]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2018-01-21 05:55 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.