Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: SQL function from DBIC

by f00li5h (Chaplain)
on Dec 07, 2008 at 16:32 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (None)
    As of 2024-09-07 17:39 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.