Skip to content

[REQUEST] Help to implement Google Query Language #398

@DanRioDev

Description

@DanRioDev

Hello there, I would love to make this happen but has little knowledge on how to.

Basically is to implement with Korma the Google Query Language: https://cloud.google.com/datastore/docs/reference/gql_reference

The grammar is

<query> :=
SELECT ( "*"
       | <property-name>+,
       | DISTINCT <property-name>+,
       | DISTINCT ON "(" <property-name>+, ")" "*"
       | DISTINCT ON "(" <property-name>+, ")" <property-name>+, )

[ FROM <kind> ]
[ WHERE <compound-condition> ]
[ ORDER BY ( <property-name> [ ASC | DESC ] )+,  ]
[ LIMIT ( <result-position> |
          FIRST "(" <result-position> ,
                    <result-position> ")" ) ]
[ OFFSET <result-position> [ "+" <result-position> ] ]

<compound-condition> := <condition>+AND

<condition> :=
  <property-name> IS NULL
| <property-name> <forward-comparator> <value>
| <value> <backward-comparator> <property-name>

<forward-comparator> :=
  <either-comparator>
| CONTAINS
| HAS ANCESTOR

<backward-comparator> :=
  <either-comparator>
| IN
| HAS DESCENDANT

<either-comparator> :=
  =
| <
| <=
| >
| >=

<result-position> := <binding-site> | <integer-literal>

<value> :=
  <binding-site>
| <synthetic-literal>
| <string-literal>
| <integer-literal>
| <double-literal>
| <boolean-literal>
| <null-literal>

<synthetic-literal> :=
  KEY "("
    [ "PROJECT" "(" <string-literal> ")" "," ]
    [ "NAMESPACE" "(" <string-literal> ")" "," ]
    <key-path-element>+, ")"
| BLOB "(" <string-literal> ")"
| DATETIME "(" <string-literal> ")"

<key-path-element> :=
  <kind> "," ( <integer-literal> | <string-literal> )

<kind> := <name>

<property-name> := <name>+.

Also there are some other differences like

MySQL Differences

MySQL supports only LIMIT/OFFSET counts. Datastore GQL also supports LIMIT/OFFSET cursors.
Datastore GQL supports an OFFSET without a LIMIT, MySQL does not.
MySQL supports an offset count via keyword LIMIT, Datastore GQL does not.
A MySQL literal string can contain a raw newline. A Datastore GQL literal string cannot.
A MySQL literal string can -escape any character. A Datastore GQL literal string can only -escape a specified list of characters.
A MySQL name can begin with a digit. A Datastore GQL name cannot.
A Datastore GQL name can contain null characters. A MySQL name cannot.
A quoted Datastore GQL name can contain -escaped characters. A quoted MySQL name interprets a \ as an ordinary character.
MySQL has different operators, keywords, and predefined names than Datastore GQL.

I little of guidance of any helping soul will be pretty appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions