Skip to content

NestedNodeRebuildingQueryDelegate findFirst method implementation actually returns the "last" #24

@kousalik

Description

@kousalik

Hi,
If I understand this correctly, all the the implementations are wrong and actually returning the last root (order by id DESC) - unlike what the method suggests.

I believe the tests (like testGetPrevSiblingRoot) pass only thanks to the behaviour of the SEQ sequence. The Y node inserted in the test gets saved with ID = 1 (first time the sequesnce is used) and the rest of the test data is behind it (ID's 1000, 2000 etc ...)

These two things combined make the test pass. I don't think this breaks anything. Mostly just makes the code tricky to understand.

We found this when implementing Mybatis version for SQL server .. where we used IDENTITY id (autoincrement) which updates the ID sequence as the test data gets inserted .. so the node Y gets ID = 16001.

EDIT: I understand that it depends on the definition of "first" but the assumption based on the growing sequence of IDs is that tha last is the node with the highest ID.

Happy to prepare PR if you agree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions