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: .query() errors when using select value #159

Open
2 tasks done
AlexFrid opened this issue Feb 14, 2025 · 1 comment
Open
2 tasks done

Bug: .query() errors when using select value #159

AlexFrid opened this issue Feb 14, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@AlexFrid
Copy link
Contributor

Describe the bug

select value returns a slightly different shape than a normal select, the fix would be to add a check for that before returning the response.
ie. response["result"][0]["result"]

Also, add a check for returning a single value

Steps to reproduce

Returning just a list
db.query("select value name from person")

Returning just a value
db.query("return 'stuff' ")

Expected behaviour

Return the results like a normal select

SurrealDB version

2.0.2 for macos on aarch64

surrealdb.py version

1.0.3

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
@AlexFrid AlexFrid added the bug Something isn't working label Feb 14, 2025
@maxwellflitton
Copy link
Contributor

From what I understand the following:

response1 = await self.connection.query("SELECT * FROM user WHERE id = user:tobie;")
print(response1)

prints out the structure below:

[{'id': RecordID(table_name=user, record_id=tobie), 'name': 'Tobie'}]

Then the following:

response2 = await self.connection.query("SELECT VALUE name FROM user WHERE id = user:tobie;")
print(response2)

Gives us the structure below:

['Tobie']

And the second one should be this?

[{'name': 'Tobie'}]

Could this be a error in the response at the database level? For instance, an example raw response I'm getting from SELECT VALUE name FROM user WHERE id = user:tobie; is:

b'\xa2bidx$86fa232d-ab78-4478-9363-ae3757b27d15fresult\x81\xa3fresult\x81eTobiefstatusbOKdtimej158.709\xc2\xb5s'

Where there's no column data. And the raw response from SELECT * FROM user WHERE id = user:tobie; is below:

b'\xa2bidx$ac31620b-d3d6-4bac-aca9-c04ca16acb39fresult\x81\xa3fresult\x81\xa2bid\xc8\x82duseretobiednameeTobiefstatusbOKdtimej250.958\xc2\xb5s'

We can see from the SELECT VALUE name FROM user WHERE id = user:tobie; raw response that there is no name field.

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

2 participants