From 2259be39e563b2f10b3a982b0244423945fb0ad4 Mon Sep 17 00:00:00 2001 From: Peter Rabbitson Date: Wed, 30 Oct 2019 21:01:22 +0100 Subject: [PATCH] Adjust passthrough example Note that further adjustments will have to be made for the DBIC version currently in 'master', but such adjustments are very likely going to be of comparable complexity to what was needed here. No warranties explicit or implicit either way. --- examples/sqla2passthrough.pl | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/examples/sqla2passthrough.pl b/examples/sqla2passthrough.pl index 8a6d0519..22c03de5 100644 --- a/examples/sqla2passthrough.pl +++ b/examples/sqla2passthrough.pl @@ -27,7 +27,25 @@ }); } -my $s = MySchema->connect('dbi:SQLite:dbname=:memory:'); +{ + package DBIx::Class::SQLMakerNG; + + use strict; + use warnings; + + require DBIx::Class::SQLMaker::ClassicExtensions; + require SQL::Abstract; + require SQL::Abstract::Classic; + + our @ISA = qw( + DBIx::Class::SQLMaker::ClassicExtensions + SQL::Abstract + SQL::Abstract::Classic + ); +} + +my $s = MySchema->connect('dbi:SQLite:dbname=:memory:', undef, undef, { on_connect_call => [ [ rebase_sqlmaker => 'DBIx::Class::SQLMakerNG' ] ] } ); + ::Dwarn([ $s->source('Foo')->columns ]); my $rs = $s->resultset('Foo')->search({ z => 1 }); @@ -42,7 +60,14 @@ ->plugin('+ExtraClauses') ->plugin('+BangOverrides'); -warn ref($s->storage->sql_maker); +# ideally his should not be needed: both plugin() and with::roles() ought +# to preserve the original mro::get_mro value, but fixup here for now +mro::set_mro( ref( $s->storage->sql_maker ), 'c3' ); + +::Dwarn { + actual_working_composite_mro => mro::get_linear_isa( ref($s->storage->sql_maker) ), + unadjusted_default_composite_mro => mro::get_linear_isa( ref($s->storage->sql_maker), 'dfs' ), +}; my $rs2 = $s->resultset('Foo')->search({ -op => [ '=', { -ident => 'outer.x' }, { -ident => 'me.y' } ]