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 math::sum() SQL function should return a number when not used as an aggregate function #65

Closed
2 tasks done
tobiemh opened this issue Aug 27, 2022 · 0 comments
Closed
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@tobiemh
Copy link
Member

tobiemh commented Aug 27, 2022

Describe the bug

When using the math::sum() function on a field which is a number, and when not using a GROUP BY clause to aggregate the record values, the function should return a number instead of NONE.

Steps to reproduce

Running the following query...

INSERT INTO player (agility, strength, scores) VALUES (10, 10, [97, 83, 79]);
INSERT INTO player (agility, strength, scores) VALUES (10, 50, [87, 90, 88]);
SELECT math::sum(strength) AS strength FROM player;

currently returns...

[
  {
    "time": "203.041µs",
    "status": "OK",
    "result": [
      {
        "strength": null
      },
      {
        "strength": null
      }
    ]
  }
]

Expected behaviour

If the value is not an array of numbers, and when not using a GROUP BY clause we would expect the function to return the field value as a number...

[
  {
    "time": "203.041µs",
    "status": "OK",
    "result": [
      {
        "strength": 10
      },
      {
        "strength": 50
      }
    ]
  }
]

SurrealDB version

surreal 1.0.0-beta.6 for macos on aarch64

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
@tobiemh tobiemh added the bug Something isn't working label Aug 27, 2022
@tobiemh tobiemh self-assigned this Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant