fix: get schema was not parsing statements with autoincrement #430
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.
Summary
When getting the schema of a table we need to parse the statement that is stored in SQLite. Sometimes that statement may come with an
AUTOINCREMENT
(because of the protocol rules that add theAUTOINCREMENT
keyword automatically when anINTEGER PRIMARY KEY
is found). However, theAUTOINCREMENT
keyword is not parsable. So we're getting an error.Context
Closes #428
Implementation overview
Simply remove the
AUTOINCREMENT
before parsing.I don't think removing keywords that are not parsable such as
STRICT
andAUTOINCREMENT
is a good long-term approach. But this is good enough to solve thebug
.This is also related to tablelandnetwork/go-sqlparser#41. It is kind of weird that the
String
method produces and string that is not compliant with the Tableland SQL. But that's more a matter of definition. Up until now, we've been using theString
method as a way to get the SQL statement that will be executed inSQLite
. I'll leave this discussion for the future.