Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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;


Comment on Re: SQL function from DBIC
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://728737]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-09-17 21:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (99 votes), past polls