Closed ckristo closed 9 years ago
I'll look at this, but we should also have #desc and #asc methods to keep with the spirit of the DSL.
@gkellogg something like query.order(asc(:o), desc(:p))
or query.order(:o).asc().order(:p).desc()
?
The SPARQL Grammar is:
[23] OrderClause ::= 'ORDER' 'BY' OrderCondition+
[24] OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression )
| ( Constraint | Var )
So, it problable need to include things such as:
query.order(:o)
query.order.asc(:o)
query.order.desc(:s).asc(:o)
where order(:c)
is a variable, and the arguments to asc
and desc
are also just variables. Trying to do a BracketedExpression or Constraint would be beyond the scope of the DSL. order.asc(:s)
would be equivalent to asc(:s)
, or even just order(:s)
, as ASC is the default. order(:s, desc: true)
or order(s: :desc)
is also reasonable. Adding more variables could loose order, but Ruby 2+ preserves order in hashes, so it's probably also reasonable.
Hashes preserve ordering since Ruby 1.9 -- I've checked that before implementing the PR (cf. 1
And as far as I remeber, sparql-client requires ruby 1.9, right?
Chris
On 27 Aug 2015, at 00:20, Gregg Kellogg notifications@github.com wrote:
I'll look at this, but we should also have #desc and #asc methods to keep with the spirit of the DSL.
— Reply to this email directly or view it on GitHub.
Hi,
based on a short discussion (issue #60) -- I added support for specifying the sort order direction with
sparql-client
's query DSL ::query.order(:var1 => :asc, :var2 => :desc)
query.order([:var1, :asc], [:var2, :desc])
Both -- Arrays and Hashes are supported as arguments. If not both should be supported, I will remove one of them.
Cheers, Chris