Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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 examining the Monastery: (6)
As of 2017-11-20 23:17 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (294 votes). Check out past polls.