Skip to content

Avoid setting the db dirty with some trailing whitespace and comments - #1543

Merged
MKleusberg merged 1 commit into
masterfrom
no_savepoints_trailing_text
Oct 30, 2018
Merged

MKleusberg merged 1 commit into
masterfrom
no_savepoints_trailing_text

Conversation

@mgrojo

@mgrojo mgrojo commented Sep 27, 2018

Copy link
Copy Markdown
Member

If we execute a select statement and there is some trailing whitespace or
comments in the buffer, we are passing that to SQLite and fooling
ourselves thinking that it may be a query modifying the database. Since
we aren't very smart about knowing which queries modify the database, this
change at least avoids this particular case by breaking when there is only
trailing whitespace and comments.

The issue has probably origin in #1455, since previously we didn't pass
the comments to SQLite.

If we execute a select statement and there is some trailing whitespace or
comments in the buffer, we are passing that to SQLite and fooling
ourselves thinking that it may be a query modifying the database. Since
we aren't very smart about knowing which queries modify the database, this
change at least avoids this particular case by breaking when there is only
trailing whitespace and comments.

The issue has probably origin in #1455, since previously we didn't pass
the comments to SQLite.
@mgrojo

mgrojo commented Sep 27, 2018

Copy link
Copy Markdown
Member Author

This was reported in the comments of #1297

@MKleusberg

Copy link
Copy Markdown
Member

Yep, I guess this is ok. The only thing to keep in mind here is that SqliteTableModel::removeCommentsFromQuery() is just as broken, especially when it comes to finding out whether a supposed comment is actually inside a string etc. But for our purpose here which is to check if there's anything left to do and to check whether a statement starts with a certain keyword or not I can't think of any statement which isn't working with this but was working before. So while it's still not perfect, it's definitely an improvement 😄

@MKleusberg
MKleusberg merged commit 23f7346 into master Oct 30, 2018
@MKleusberg
MKleusberg deleted the no_savepoints_trailing_text branch October 30, 2018 21:01
@mgrojo

mgrojo commented Oct 30, 2018

Copy link
Copy Markdown
Member Author

Yes, I'm aware of that and agree to all you've said.

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

Successfully merging this pull request may close these issues.

2 participants