Skip to content

[Bug] Query with filter on an integer column. (JS has number not int and float) #754

Open
@vicb

Description

@vicb
  1. Is this a client library issue or a product issue?

I guess a bug in the client library ("@google-cloud/datastore": "^6.3.0")

Environment details

  • OS: Linux
  • Node.js version: 14.15
  • npm version: 6.14.8
  • @google-cloud/datastore version: 6.3.0

Steps to reproduce

  1. Create an entity in the cloud console with an integer column, named integer_column and set its value to 200.

  2. Executes a query with a filter on that column:

    const query = datastore
      .createQuery(tableName)
      .filter('integer_column', '>', value);

    const [results] = await datastore.runQuery(query);

Expected behavior:

The correct results are returned if value is a valid numerical value, i.e. 123 or 123.456

Actual behavior

The correct results are only returned if value is 123. A float value (123.456) would return an empty result.

Workaround

Update the query to add Math.round().

    const query = datastore
      .createQuery(tableName)
      .filter('integer_column', '>', Math.round(value));

    const [results] = await datastore.runQuery(query);

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: datastoreIssues related to the googleapis/nodejs-datastore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions