Avoid setting the db dirty with some trailing whitespace and comments by mgrojo · Pull Request #1543 · sqlitebrowser/sqlitebrowser

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

Conversation

@mgrojo

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

This was reported in the comments of #1297

@MKleusberg

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 😄

@mgrojo

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

3 participants

@mgrojo @MKleusberg