Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: The alphabetical order of the properties of an object-based Record ID is query-significant #4053

Open
2 tasks done
ioannist opened this issue May 17, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@ioannist
Copy link

Describe the bug

REMOVE TABLE wallet;

UPDATE wallet:{
    a: 0,
    b: 0,
    c: 0,
    d: 5
};
UPDATE wallet:{
    a: 0,
    b: 1,
    c: 0,
    d: 6
};
UPDATE wallet:{
    a: 0,
    b: 1,
    c: 1,
    d: 7
};
UPDATE wallet:{
    a: 1,
    b: 0,
    c: 1,
    d: 8
};
UPDATE wallet:{
    a: 0,
    b: 0,
    c: 0,
    d: 9
};

RETURN array::len(SELECT * FROM wallet:{a:0, b:0, c:0, d: 9}..={a:1, b:1, c:1, d: 10});


REMOVE TABLE wallet;

UPDATE wallet:{
    d: 0,
    c: 0,
    b: 0,
    a: 5
};
UPDATE wallet:{
    d: 0,
    c: 1,
    b: 0,
    a: 6
};
UPDATE wallet:{
    d: 0,
    c: 1,
    b: 1,
    a: 7
};
UPDATE wallet:{
    d: 1,
    c: 0,
    b: 1,
    a: 8
};
UPDATE wallet:{
    d: 0,
    c: 0,
    b: 0,
    a: 9
};

RETURN array::len(SELECT * FROM wallet:{d:0, c:0, b:0, a: 9}..={d:1, c:1, b:1, a: 10});

Steps to reproduce

Execute above code.

The first array has length 4 and the second has length 1.

The datasets are exactly the same with the property names reversed, which implies that the value lookup happens in the alphabetical order of the properties.

Expected behaviour

The arrays should have equal lengths. Alternatively, the alphabetical ordering should be documented.

SurrealDB version

1.5

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ioannist ioannist added bug Something isn't working triage This issue is new labels May 17, 2024
@Dhghomon
Copy link
Contributor

You're right that objects are alphabetically sorted and in fact we were just discussing adding that documentation last week. One PR is on its way to clarify that:

https://github.com/surrealdb/docs.surrealdb.com/pull/534/files

Another one will be coming up on sorting and how comparisons/range scans can be done on all values regardless of the type. (Which is why you sometimes see record range scans starting from NONE, which is the absolute starting point)

@Dhghomon Dhghomon added documentation Improvements or additions to documentation and removed bug Something isn't working triage This issue is new labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants