Server IP : 85.214.239.14 / Your IP : 3.133.122.95 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/cwd/proc/3/root/usr/share/doc/libsql-abstract-perl/examples/ |
Upload File : |
use strict; use warnings; use Devel::Dwarn; use With::Roles; { package MySchema; use Object::Tap; use base qw(DBIx::Class::Schema); use DBIx::Class::ResultSource::Table; __PACKAGE__->register_source( Foo => DBIx::Class::ResultSource::Table->new({ name => 'foo' }) ->$_tap(add_columns => qw(x y z)) ); __PACKAGE__->register_source( Bar => DBIx::Class::ResultSource::Table->new({ name => 'bar' }) ->$_tap(add_columns => qw(x y1 y2 z)) ); } { package MyScratchpad; use DBIx::Class::SQLMaker::Role::SQLA2Passthrough qw(on); MySchema->source('Foo')->add_relationship(bars => 'Bar' => on { +{ 'foreign.x' => 'self.x', 'foreign.y1' => { '<=', 'self.y' }, 'foreign.y2' => { '>=', 'self.y' }, }; }); } my $s = MySchema->connect('dbi:SQLite:dbname=:memory:'); ::Dwarn([ $s->source('Foo')->columns ]); my $rs = $s->resultset('Foo')->search({ z => 1 }); ::Dwarn(${$rs->as_query}->[0]); $s->storage->ensure_connected; $s->storage ->sql_maker ->with::roles('DBIx::Class::SQLMaker::Role::SQLA2Passthrough') ->plugin('+ExtraClauses') ->plugin('+BangOverrides'); warn ref($s->storage->sql_maker); my $rs2 = $s->resultset('Foo')->search({ -op => [ '=', { -ident => 'outer.x' }, { -ident => 'me.y' } ] }, { 'select' => [ 'me.x', { -ident => 'me.z' } ], '!with' => [ outer => $rs->get_column('x')->as_query ], }); ::Dwarn(${$rs2->as_query}->[0]); my $rs3 = $s->resultset('Foo') ->search({}, { prefetch => 'bars' }); ::Dwarn(${$rs3->as_query}->[0]); $s->source('Foo')->result_class('DBIx::Class::Core'); $s->source('Foo')->set_primary_key('x'); my $rs4 = $s->resultset('Foo')->new_result({ x => 1, y => 2 }) ->search_related('bars'); ::Dwarn(${$rs4->as_query}->[0]);