use base qw(Exporter);
-our @EXPORT = qw(expr SELECT AS FROM BY JOIN ON LEFT);
+our @EXPORT = qw(expr SELECT AS FROM BY JOIN ON LEFT WHERE ORDER GROUP);
sub expr (&) {
_run_expr($_[0])->{expr};
}
sub _value {
- ref($_[0]) ? $_[0]->{expr} : perl_scalar_value($_[0])
+ if ($_[0]->$_isa('Data::Query::ExprBuilder')) {
+ $_[0]->{expr};
+ } elsif (ref($_[0])) {
+ $_[0]
+ } else {
+ perl_scalar_value($_[0]);
+ }
}
sub AS {
_value($from[0]);
}
};
- while ($_[0] and is_Join($_[0])) {
+ while (is_Join($_[0])) {
$from_dq = { %{+shift}, left => $from_dq };
}
+ if (is_Where($_[0])) {
+ $from_dq = Where(shift->{where}, $from_dq);
+ }
return $from_dq;
- die "Huh?"
}
sub LEFT {
LEFT JOIN { $_->cds, AS 'cd' }
ON { $_->cd->artistid eq $_->artist->id }
);
+DwarnL render_expr(
+ SELECT { $_->artist->name } WHERE { $_->artist->age > 25 }
+);
+DwarnL render_expr(
+ SELECT { $_->cd->name }
+ FROM { $_->cds, AS 'cd' }
+ JOIN { $_->artists, AS 'artist' }
+ ON { $_->cd->artistid eq $_->artist->id }
+ WHERE { $_->artist->age > 25 }
+);