--- /dev/null
+package DBIx::Class::SQLMaker::SQLA2Support;
+
+use strict;
+use warnings;
+use if $] < '5.010', 'MRO::Compat';
+use mro 'c3';
+use base qw(
+ DBIx::Class::SQLMaker
+ SQL::Abstract::ExtraClauses
+);
+
+sub select {
+ my $self = shift;
+ my ($sql, @bind) = $self->next::method(@_);
+ my (undef, undef, undef, $attrs) = @_;
+ if (my $with = delete $attrs->{with}) {
+ my ($wsql, @wbind) = @{ $self->render_statement({
+ -select => { with => $with }
+ }) };
+ unshift @bind, @wbind;
+ $sql = "${wsql} ${sql}";
+ }
+ return wantarray ? ($sql, @bind) : $sql;
+}
+
+1;
$self->{expand}{exists} = sub {
$_[0]->_expand_op(undef, [ exists => $_[2] ]);
};
+
+ # check for overriden methods
+ if ($self->can('_table') ne SQL::Abstract->can('_table')) {
+ $self->{expand_clause}{'select.from'} = sub {
+ return +{ -literal => [ $_[0]->_table($_[2]) ] };
+ };
+ }
+ if ($self->can('_order_by') ne SQL::Abstract->can('_order_by')) {
+ $self->{expand_clause}{'select.order_by'} = sub {
+ my ($osql, @obind) = $_[0]->_order_by($_[2]);
+ $osql =~ s/^order by //i;
+ return undef unless length($osql);
+ return +{ -literal => [ $osql, @obind ] };
+ };
+ }
return $self;
}
sub select {
my ($self, @args) = @_;
-
my $stmt = do {
if (ref(my $sel = $args[0]) eq 'HASH') {
$sel
Class::C3::Componentised->ensure_class_loaded($_) for @comp_classes;
Class::C3::Componentised->inject_base(
$new_class,
- @comp_classes, $class,
+ @comp_classes, $class
);
+ mro::set_mro($new_class, 'c3');
return $new_class unless ref($inv);
return bless($inv, $new_class);
}