GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Datastore query fails when including a sort and a filter. · Issue #1402 · googleapis/google-cloud-node

Datastore query fails when including a sort and a filter. #1402

New issue
Copy link
New issue
Copy link
Closed
Closed
Datastore query fails when including a sort and a filter.#1402
Copy link
Assignees
pcostell
Labels
api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Description

@bamapookie
bamapookie
opened on Jun 30, 2016
Issue body actions

gcloud datastore.runQuery fails with a "412 Precondition Failed" when the query contains a filter and a sort. Below is a mocha test that creates a new datastoreKind, adds two records, then queries for the record. The only difference between the queries is that the third query contains both a filter and a sort.

'use strict';

var datastore = require('gcloud').datastore({
    projectId: 'test-playground',
    keyFilename: './serviceAccountCredentials.json'
});
var kind = 'Scratch-' + require('node-uuid').v4();

describe('Datastore Filter', function () {
    it('should add two records', function (done) {
        datastore.upsert({
            key: {namespace: 'Scratch', path: [kind]},
            data: {category: 'Scratch', date: new Date(), text: 'Find me too!'}
        }, function () {
            datastore.upsert({
                key: {namespace: 'Scratch', path: [kind]},
                data: {category: 'Scratch', date: new Date(), text: 'Find me!'}
            }, done);
        });
    });
    it('should find records sorted by date', function (done) {
        var query = datastore
            .createQuery('Scratch', kind)
            .order('date', {descending: true});
        datastore.runQuery(query, function (err) {
            if (err) done(err);
            else done();
        });
    });
    it('should find records matching a filter', function (done) {
        var query = datastore
            .createQuery('Scratch', kind)
            .filter('category', 'Scratch');
        datastore.runQuery(query, function (err) {
            if (err) done(err);
            else done();
        });
    });
    it('should find records matching a filter sorted by date', function (done) {
        var query = datastore
            .createQuery('Scratch', kind)
            .filter('category', 'Scratch')
            .order('date', {descending: true});
        datastore.runQuery(query, function (err) {
            if (err) done(err);
            else done();
        });
    });
});

Activity

  1. bamapookie
    changed the title [-]Datastore query fails when including a filter.[/-] [+]Datastore query fails when including a sort and a filter.[/+] on Jun 30, 2016
  2. bamapookie commented on Jun 30, 2016

    @bamapookie
    bamapookie
    on Jun 30, 2016
    ContributorAuthor
    More actions

    Note: Updated to include that the combination of sort and filter causes the failure.

  3. stephenplusplus commented on Jun 30, 2016

    @stephenplusplus
    stephenplusplus
    on Jun 30, 2016
    Contributor
    More actions

    // @pcostell

  4. stephenplusplus
    added
    api: datastoreIssues related to the Datastore API.
    on Jun 30, 2016
  5. pcostell commented on Jun 30, 2016

    @pcostell
    pcostell
    on Jun 30, 2016
    Contributor
    More actions

    The combination of filter and sort requires an index to be defined. You should have an index.yaml file that includes:

    indexes:
      - kind: Scratch
        properties:
        - name: category
        - name: date
          direction: desc
    
  6. pcostell
    closed this as completedon Jun 30, 2016
  7. stephenplusplus
    added
    type: questionRequest for information or clarification. Not an issue.
    on Jun 30, 2016
  8. bamapookie commented on Jul 1, 2016

    @bamapookie
    bamapookie
    on Jul 1, 2016
    ContributorAuthor
    More actions

    Thanks. I updated the original comment to be consistent with the updated code.

  9. JustinBeckwith
    assigned
    pcostell
    on Feb 1, 2021
  10. sofisl
    added a commit that references this issue on Feb 3, 2026

    fix: throw timeout error when using jobs.query (#1402)

    ed63b40
  11. sofisl
    added a commit that references this issue on Feb 26, 2026

    docs: fix the broken link and improve jsdocs (#1402)

    b52282f
  12. GautamSharda
    added 2 commits that reference this issue on Mar 11, 2026

    fix: deprecate maxExtension in favour of maxExtensionMinutes (#1402)

    2d6ba3d

    chore: release 2.18.1 (#1403)

    b297983
  13. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    chore(deps): update dependency gapic-tools to ^0.4.0 (#1402)

    cf971b6

    chore(deps): update dependency gapic-tools to ^0.4.0 (#1402)

    1cd6033
  14. feywind
    added a commit that references this issue on Mar 27, 2026

    chore: release 2.18.1 (#1403)

    9f02d41
  15. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    chore(deps): update dependency gapic-tools to ^0.4.0 (#1402)

    c17099c
  16. thiyaguk09
    added a commit that references this issue on May 5, 2026

    chore(deps): update dependency gapic-tools to ^0.4.0 (googleapis#1402)

    e7afb6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @pcostell
    pcostell

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.