use strict;
use warnings;
+use Module::Runtime ();
use Carp ();
use List::Util ();
use Scalar::Util ();
',' => '_render_op_multop',
};
+ if ($opt{lazy_join_sql_parts}) {
+ my $mod = Module::Runtime::use_module('SQL::Abstract::Parts');
+ $opt{join_sql_parts} ||= sub { $mod->new(@_) };
+ }
+
+ $opt{join_sql_parts} ||= sub { join $_[0], @_[1..$#_] };
+
return bless \%opt, $class;
}
: ((ref($_) eq 'ARRAY') ? $_ : [ $_ ])
), @parts;
return [
- join($join, map $_->[0], @final),
+ $self->{join_sql_parts}->($join, map $_->[0], @final),
(map @{$_}[1..$#$_], @final),
];
}
return () unless defined(my $expanded = $self->_expand_order_by($arg));
- return $self->_chunkify_order_by($expanded);
+ my @res = $self->_chunkify_order_by($expanded);
+ (ref() ? $_->[0] : $_) .= '' for @res;
+ return @res;
}
sub _chunkify_order_by {
--- /dev/null
+package SQL::Abstract::Parts;
+
+use strict;
+use warnings;
+
+use overload '""' => 'stringify', fallback => 1;
+
+sub new {
+ my ($proto, @args) = @_;
+ bless(\@args, ref($proto) || $proto);
+}
+
+sub stringify {
+ my ($self) = @_;
+ my ($join, @parts) = @$self;
+ return join $join, @parts;
+}
+
+1;