Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Multiple Inserts #28

Open
techedemic opened this issue Mar 6, 2018 · 2 comments
Open

Feature request: Multiple Inserts #28

techedemic opened this issue Mar 6, 2018 · 2 comments

Comments

@techedemic
Copy link

techedemic commented Mar 6, 2018

Using MySQL as target, I can insert multiple values at once using the following syntax

INSERT INTO mytable 
(id,first_name,last_name) 
VALUES (1,'John','Doe'),
VALUES (2,'Jane','Doe'),
VALUES (3,'Donald','Trump'),

However, using the SQL parser, I can only do 1 at a time.

So, if I parse the following statement:

INSERT INTO mytable (id,first_name,last_name) VALUES (1,'John','Doe')

... I get the following result

{
  "status": true,
  "value": {
    "type": "insert",
    "into": {
      "table": "mytable",
      "alias": null,
      "expression": "mytable"
    },
    "values": [
      {
        "target": {
          "expression": "id",
          "column": "id"
        },
        "value": "1"
      },
      {
        "target": {
          "expression": "first_name",
          "column": "first_name"
        },
        "value": "'John'"
      },
      {
        "target": {
          "expression": "last_name",
          "column": "last_name"
        },
        "value": "'Doe'"
      }
    ]
  }
}

But if I parse the following statement:

INSERT INTO mytable (id,first_name,last_name) VALUES (1,'John','Doe'),(2,'Jane','Doe'), (3,'Donald','Trump')

...I get the following error

{
  "status": false,
  "index": 69,
  "expected": [
    "EOF"
  ],
  "error": "expected EOF at character 69, got '...,(2,'Jane','...'"
}
@dsferruzza
Copy link
Owner

Hi!

I thought the syntax for multiple insertions was:

INSERT INTO mytable (id,first_name,last_name) VALUES (1,'John','Doe'), (2,'Jane','Doe'), (3,'Donald','Trump')

I guess both work...

But anyway this is not currently supported by both the AST and (as a consequence) the parser :/
Support of multiple insertions might not be a big challenge but it is not something I can fix quickly either...

I currently have not enough free time and motivation to work on this (also, this project would require a big cleanup before adding new features), but I can try to provide you advice.
If this is critical to you feel free to send me an email and we can discuss options.

Have a nice day!

@techedemic
Copy link
Author

Apologies, that was a typo on my side....I copied and pasted too eagerly there..
Your syntax is the correct one and the 'only' correct one at that.

Look, it's not a train smash, I can work around it...but I would prefer we not 'close' this request and perhaps leave it as is until you can get to it or, maybe, when I have time I'll give it a go myself an do a pull request.

Thanks for the speedy reply. I''ll edit my original post to correct the syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants