Code Monkey home page Code Monkey logo

Comments (4)

nwronski avatar nwronski commented on July 24, 2024

Yes, this group of nodes has a lot of inconsistency: IF EXISTS and IF NOT EXISTS.

I have reworked to be a little more consistent across the different places these can appear:

  • Use expression node in condition for IF NOT EXISTS. NOT EXISTS, and EXISTS modifiers instead of a string value
create table if not exists foo(id int)

CREATE TABLE Statement AST

{
  "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 if exists foo

DROP TABLE Statement AST

{
  "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"
      }
    }
  ]
}
select a
where not exists (select b)

NOT EXISTS Expression AST

{
  "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"
    }
  ]
}

Tagged the wrong issue in the commit, but the proposed changes are in this commit.

from sqlite-parser.

nwronski avatar nwronski commented on July 24, 2024

Included in latest sqlite-parser@beta release v1.0.0-rc2.

from sqlite-parser.

jdrew1303 avatar jdrew1303 commented on July 24, 2024

Sorry about the original issue. It sounded a bit blunt 🤔 I do most of my work on this at night. 😜

New nodes are working perfect. Almost no work on my part to fit them into the generator. 👍 I haven't hit any issues with them either. So they're good to go. Thanks for the work on this. I appreciate it.

from sqlite-parser.

nwronski avatar nwronski commented on July 24, 2024

@jdrew1303 Awesome, I think we are getting pretty close now. Have you found any other issues since the last round of changes? This might be last call for changes before I release v1.0.0.

from sqlite-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.