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

Release v1.0.0-rc2

Pre-release
Pre-release
Compare
Choose a tag to compare
@nwronski nwronski released this 31 Oct 00:26
· 8 commits to master since this release

Changed

  • BREAKING CHANGE All named values for properties such as variant, format, and type should always be lowercase, even when uppercase in the input SQL (e.g., variant is now natural join instead of NATURAL JOIN in the AST).

  • BREAKING CHANGE New format for CASE expression AST nodes:

    • variant when has a condition and a consequent
    • variant else has just a consequent
    • the outer expression is now variant case instead of binary
    • instead of taking whatever is provided between CASE and WHEN (e.g., CASE foo WHEN ...) and calling that the expression, it is now added as the discriminant
    select
        case acc
          when a = 0 then a1
          when a = 1 then b1
          else c1
        end
    {
      "type": "expression",
      "variant": "case",
      "expression": [
        {
          "type": "condition",
          "variant": "when",
          "condition": {
            "type": "expression",
            "format": "binary",
            "variant": "operation",
            "operation": "=",
            "left": {
              "type": "identifier",
              "variant": "column",
              "name": "a"
            },
            "right": {
              "type": "literal",
              "variant": "decimal",
              "value": "0"
            }
          },
          "consequent": {
            "type": "identifier",
            "variant": "column",
            "name": "a1"
          }
        },
        {
          "type": "condition",
          "variant": "when",
          "condition": {
            "type": "expression",
            "format": "binary",
            "variant": "operation",
            "operation": "=",
            "left": {
              "type": "identifier",
              "variant": "column",
              "name": "a"
            },
            "right": {
              "type": "literal",
              "variant": "decimal",
              "value": "1"
            }
          },
          "consequent": {
            "type": "identifier",
            "variant": "column",
            "name": "b1"
          }
        },
        {
          "type": "condition",
          "variant": "else",
          "consequent": {
            "type": "identifier",
            "variant": "column",
            "name": "c1"
          }
        }
      ],
      "discriminant": {
        "type": "identifier",
        "variant": "column",
        "name": "acc"
      }
    }
  • BREAKING CHANGE New format for EXISTS expression nodes. Use expression node in condition for IF NOT EXISTS. NOT EXISTS, and EXISTS modifiers instead of a string value.

    • CREATE TABLE statement

      create table if not exists foo(id int)
      {
        "type": "statement",
        "name": {
          "type": "identifier",
          "variant": "table",
          "name": "foo"
        },
        "variant": "create",
        "format": "table",
        "definition": [
          {
            "type": "definition",
            "variant": "column",
            "name": "id",
            "definition": [],
            "datatype": {
              "type": "datatype",
              "variant": "int",
              "affinity": "integer"
            }
          }
        ],
        "condition": [
          {
            "type": "condition",
            "variant": "if",
            "condition": {
              "type": "expression",
              "variant": "exists",
              "operator": "not exists"
            }
          }
        ]
      }
    • DROP TABLE statement

      drop table if exists foo
      {
        "type": "statement",
        "target": {
          "type": "identifier",
          "variant": "table",
          "name": "foo"
        },
        "variant": "drop",
        "format": "table",
        "condition": [
          {
            "type": "condition",
            "variant": "if",
            "condition": {
              "type": "expression",
              "variant": "exists",
              "operator": "exists"
            }
          }
        ]
      }
    • NOT EXISTS expression

      select a
      where not exists (select b)
      {
        "type": "statement",
        "variant": "select",
        "result": [
          {
            "type": "identifier",
            "variant": "column",
            "name": "a"
          }
        ],
        "where": [
          {
            "type": "expression",
            "format": "unary",
            "variant": "exists",
            "expression": {
              "type": "statement",
              "variant": "select",
              "result": [
                {
                  "type": "identifier",
                  "variant": "column",
                  "name": "b"
                }
              ]
            },
            "operator": "not exists"
          }
        ]
      }