[MGNLGQL-55] Limit and offset arguments are not behaving correctly Created: 20/Oct/20  Updated: 16/Nov/20  Resolved: 03/Nov/20

Status: Closed
Project: Magnolia GraphQL
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0

Type: Bug Priority: Neutral
Reporter: Ondrej Chytil Assignee: Jaroslav Simak
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: GraphQL Phase 1
Sprint: HL & LD 14, HL & LD 15
Story Points: 3

 Description   

Reproduction steps:

  • set i18n: true on subModel field

Eg.:
limit:4 returns 2 items
limit:4, offset:1 return 3 items and wrong ones
etc.



 Comments   
Comment by Jaroslav Simak [ 20/Oct/20 ]

This is caused by how the JCR query is using limit and offset with localized subModel, JOIN and RowIterator – looks like we'll have to do limit and offset ourselves when there's a submodel involved.

Localized subModel leads into having two nodes under the model, example:

/myModel
/myModel/mySubModel
/myModel/mySubModel_de

The RowIterator will return N sub nodes (where N is number of locales under the main node), making limit and offset behave incorrectly for our use case. We can use NAME operand in the WHERE clause to force child nodes to a certain name (name of the subModel in our case).

Here's a working snippet from Groovy with NAME operand (position is localized):

def sess = ctx.getJCRSession("books")
def query = "SELECT * FROM [lib:book] AS t LEFT OUTER JOIN [mgnl:contentNode] AS ch0 ON ISCHILDNODE(ch0, t) WHERE NAME(ch0) = 'position'"
def result = sess.getWorkspace().getQueryManager().createQuery(query, "JCR-SQL2").execute();
def iterator = result.getRows()
iterator.each { row ->
    println row
}

Above query will not produce ambiguous result that is based on number of locales saved under the main node.

Generated at Mon Feb 12 05:52:08 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.