Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm adding BASIC insert support for sqlite.
New feature for sqlite:
Previously
sqlc
is unable to generate inserts for sqlite because it was simply returningast.TODO
.I'm implementing a basic support for inserts although "some gymnastics" are required to work with the parser.
The main problem is that the parser gives a list of expressions so, take the following example:
In this case the parser would give you a slice of 4 bind expression, the ONLY way to know how to generate the
ast.List
required is to have the columns explicit in the query.Currently, it seems impossible to generate the correct instruction for the following sql
In this case, we are screwed. Values are not "grouped" in any meaningful way. This can be solved by a quick "hack" but I really didn't dive deep in the parser as well to go with the hack approach. This is the reason why we are forced to explicitly put the columns on the insert. You would get a parser error if you want to do the query above although sqlite has no problem with this type of update.
I want to support INSERT with SELECT but that would be another kind of beast to tame. In the mean time, basic INSERT support is all that I needed in my project.
I'm open to comments, suggestions, questions and concerns.