where => {
type => DQ_OPERATOR,
operator => {
- 'SQL.Naive' => $dq->{offset} ? 'BETWEEN' : '<'
+ 'SQL.Naive' => (
+ $dq->{offset}
+ ? 'BETWEEN'
+ : $order_nodes[0]{reverse} ? '>' : '<'
+ ),
},
args => [
{
},
where => {
type => DQ_OPERATOR,
- operator => { 'SQL.Naive' => '<' },
+ operator => {
+ 'SQL.Naive' => $order_nodes[0]{reverse} ? '>' : '<'
+ },
args => [
map +{
type => DQ_IDENTIFIER,
}
},
},
- $dq->{limit},
- ($dq->{offset} ? ($dq->{offset} : ())),
+ ($dq->{offset}
+ ? ($dq->{offset},
+ { %{$dq->{limit}},
+ value => $dq->{offset}{value} + $dq->{limit}{value} - 1
+ }
+ )
+ : ($dq->{limit})
+ ),
]
},
};
(ref($select[0]) eq 'LIES::AS'
? +{
type => DQ_ALIAS,
- alias => $e->{expr},
- as => ${shift(@select)}
+ from => $e->{expr},
+ to => ${shift(@select)}
}
: $e->{expr}
);