Skip to content
This repository has been archived by the owner on Jul 15, 2021. It is now read-only.

Standard AST across all statement types (v1.0.0) #3

Closed
7 tasks done
nwronski opened this issue Jul 9, 2015 · 1 comment
Closed
7 tasks done

Standard AST across all statement types (v1.0.0) #3

nwronski opened this issue Jul 9, 2015 · 1 comment
Assignees

Comments

@nwronski
Copy link
Contributor

nwronski commented Jul 9, 2015

  • [In Progress] Finish standardizing AST format across all types of statements
    • ORDER BY
    • LIMIT
    • name property across node types
    • type and variant combine into single type property Move to v2.0.0 milestone
    • target
  • [DONE] Organize tests and SQL test queries by type and split out into different files/directories.
@nwronski nwronski added this to the Standardized AST milestone Jul 9, 2015
nwronski added a commit that referenced this issue Jul 10, 2015
…t files and directories by type, define mocha.opts to run tests directory recursively. refs #3
nwronski added a commit that referenced this issue Jul 10, 2015
nwronski added a commit that referenced this issue Sep 29, 2015
Taking steps to remove properties that are not required in
the AST such as default/null values and automatically
adding obscure properties by default. Especially properties such as autoIncrement and temporary.
nwronski added a commit that referenced this issue Sep 29, 2015
Replaced grunt json with grunt rewrite to automatically
generate new test JSON files for all the specs.

Instead of parsing a JSON string in the spec JS file, the
helper now looks for a file in the "test/json/" folder that
matches the SQL file loaded from "test/sql/".
nwronski added a commit that referenced this issue Sep 29, 2015
Only include 'optimization' when it contains a value.
nwronski added a commit that referenced this issue Sep 29, 2015
Working version of "grunt rewrite-json" that also runs the
specs after generating each new JSON file.
nwronski added a commit that referenced this issue Sep 29, 2015
nwronski added a commit that referenced this issue Sep 29, 2015
Still had some null values for column constraint names.
nwronski added a commit that referenced this issue Sep 29, 2015
nwronski added a commit that referenced this issue Sep 29, 2015
Previous 0.12.0 should have been tagged beta and not set
as default release.

Refs #3
@jdrew1303
Copy link

Hi @nwronski

I was wondering if you were still working on standardising the node type and variant? I'm working on an AST walker based off the Estraverse code base and I've encountered some issue with nodes not having types on them (eg the on property). I can bypass it if necessary but it slows walking down. Every key has to be visited and checked to see if there is an object or array to walk into instead of knowing in advance where it needs to go.

If you're not working on it would it be ok for me to submit pull requests to add types to the nodes? They will be quite simplistic to allow the walker to get up and running but I wouldnt mind working on the full refactor of type and variant if you could do with some help?

nwronski added a commit that referenced this issue Oct 2, 2016
Got rid of a bunch of unused code, cleaned up the utility
functions, moved the utilities back into the grammar.pegjs file to
avoid the extra magic of injecting the import statement into the
built parser.

Fixed the binary expression logic to properly handle cases such
as:

``` sql
SELECT * FROM t where -1 * (2 + 3);
SELECT * FROM t where 3 + 4 * 5 > 20;
SELECT * FROM t where v1 = ((v2 * 5) - v3);
```

Updated SQL in specs to contain correct ASTs for specs related
to expression grouping.

Should have broken this into several commits but the changes
are too intertwined to easily break apart now.

Refs #20
Refs #3
nwronski added a commit that referenced this issue Oct 3, 2016
The root node of the AST now has `type` and `variant`
properties:

``` json
{
  "type": "statement",
  "variant": "list",
  "statement": [{
    "type": "statement",
    "variant": "select",
    "statement": {}
  }]
}
```
nwronski added a commit that referenced this issue Oct 4, 2016
Indexed columns (e.g., the column list in the `ON` part of a
`CREATE INDEX` statement) and ordering expressions (e.g., the
`ORDER BY` part of a `SELECT` statement) now have the
following format:

- When they are proceeded by an ordering term (e.g., `ASC`, `DESC`) and/or `COLLATE`, such as `ORDER BY nick ASC`
- But, when it is only an expression or column name without any ordering term or `COLLATE` then it will only be the expression itself, and the implicit `"direction": "asc"` will not be added to the AST, such as `ORDER BY nick`

Refs #3
nwronski added a commit that referenced this issue Oct 4, 2016
Allow dbName.tableName format in a qualified table expression.
nwronski added a commit that referenced this issue Oct 4, 2016
The definition for indexed columns and ordering expressions
allows for a COLLATE part, but that is already part of the
grammar for expression so it is redundant to have it explicitly
added to these other rules.

Refs #3
nwronski added a commit that referenced this issue Oct 4, 2016
Indexed columns (e.g., the column list in the `ON` part of a
`CREATE INDEX` statement) and ordering expressions (e.g., the
`ORDER BY` part of a `SELECT` statement) now have the
following format:

- When they are proceeded by an ordering term (e.g., `ASC`, `DESC`) and/or `COLLATE`, such as `ORDER BY nick ASC`
- But, when it is only an expression or column name without any ordering term or `COLLATE` then it will only be the expression itself, and the implicit `"direction": "asc"` will not be added to the AST, such as `ORDER BY nick`

Refs #3
@nwronski nwronski closed this as completed Oct 9, 2016
@nwronski nwronski self-assigned this Oct 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants