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 bindings for array-valued bindings broken #332

Open
2 tasks done
lylejohnson opened this issue Aug 22, 2024 · 3 comments
Open
2 tasks done

Bug: Query bindings for array-valued bindings broken #332

lylejohnson opened this issue Aug 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@lylejohnson
Copy link

Describe the bug

I'm updating my code base from surrealdb.js version 0.11.1 to surrealdb version 1.0.0-beta.20 and running into a snag. I have this query which returns the expected result set, whether I run it in Surrealist.app:

SELECT VALUE <-belongs_to_model_schema<-entity_schema AS e FROM model_schema WHERE id in $modelSchemaIds FETCH e

or using the 0.11.1 SDK:

const modelSchemaIds = ['model_schema:x'];
const response = await this.query('SELECT VALUE <-belongs_to_model_schema<-entity_schema AS e FROM model_schema WHERE id in $modelSchemaIds FETCH e', { modelSchemaIds });

However, when I attempt this query using SDK 1.0.0-beta.20, I'm getting an empty result set!

Steps to reproduce

See description

Expected behaviour

I'd expect to get the same results that I was getting for SDK version 0.11.1.

SurrealDB version

surreal 1.5.4 for linux on x86_64

JavaScript SDK version

0.0.1-beta.20

Contact Details

[email protected]

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
@lylejohnson lylejohnson added the bug Something isn't working label Aug 22, 2024
@lylejohnson
Copy link
Author

Figured it out (sort of): It's not processing the query bindings properly. If I change the query call from this:

const modelSchemaIds = ['model_schema:x'];
const response = await this.query('SELECT VALUE <-belongs_to_model_schema<-entity_schema AS e FROM model_schema WHERE id IN $modelSchemaIds FETCH e', { modelSchemaIds });

to this:

const modelSchemaIds = ['model_schema:x'];
const response = await this.query(`SELECT VALUE <-belongs_to_model_schema<-entity_schema AS e FROM model_schema WHERE id IN [${modelSchemaIds.map(modelSchemaId => `"${modelSchemaId}"`).join(', ')}] FETCH e`, { modelSchemaIds });

then I get the expected results.

@lylejohnson lylejohnson changed the title Bug: Query returns no results Bug: Query bindings for array-valued bindings broken Aug 22, 2024
@lylejohnson
Copy link
Author

lylejohnson commented Aug 22, 2024

Also works if I map them to StringRecordId instances:

const modelSchemaIds = ['model_schema:x'];
const response = await this.query(
    'SELECT VALUE <-belongs_to_model_schema<-entity_schema AS e FROM model_schema WHERE id IN $modelSchemaIds FETCH e',
    {
        modelSchemaIds.map(modelSchemaId => new StringRecordId(modelSchemaId)
    }
);

@drdrei
Copy link

drdrei commented Dec 5, 2024

Still broken in v1.1.0.
surreal.query('select ->friends->user.* from only $auth;') returns records in the nested response object.
surreal.query('select value ->friends->user.* from only $auth;') returns no records. Running this query against the DB (in Surrealist) returns the expected records.

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