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

Initialising a new database #319

Closed
mordante opened this issue Sep 15, 2016 · 2 comments
Closed

Initialising a new database #319

mordante opened this issue Sep 15, 2016 · 2 comments

Comments

@mordante
Copy link

I ran into an issue while creating a new database with a new user account. The problem is the application does not start when creating a new database, with a SQL error. I've seen the issue before but it is rather elusive to reproduce. It seems to have to do with SQL escaping. I think I have a solution, but since reproducing the issue is hard, it's hard to validate the fix. I expect to have a proper pull request next weekend. (If I fail to find a proper fix I'll give more details on the bug.)

I consider this issue a blocker for 2.4.0, but it does not affect translatable strings.

mordante added a commit to mordante/brewtarget that referenced this issue Sep 16, 2016
While initialising the database for a new user a random issue occurred.
Every now and then the initialisation failed with a SQL error.
The issue seemed to happen with a record named something like
»Harry's rolled…«. I have not investigated why it is random, nor was I
able to find a similar record in the database.

In order to reproduce the issue I modified the default_db.sqlite database.
I changed the fermentable entry for »Acid Malt« to »Acid Malt'X«. This led
to a reproducible error:

[20:22:44.468] ERROR : void Database::populateChildTablesByName(Brewtarget::DBTable) SELECT id FROM fermentable WHERE ( name='Acid Malt'X' AND display=1 ) ORDER BY id ASC LIMIT 1 unrecognized token: "X' AND display=1 ) ORDER BY id ASC LIMIT 1" Unable to execute statement
[20:22:44.468] ERROR : void Database::populateChildTablesByName() void Database::populateChildTablesByName(Brewtarget::DBTable) SELECT id FROM fermentable WHERE ( name='Acid Malt'X' AND display=1 ) ORDER BY id ASC LIMIT 1 unrecognized token: "X' AND display=1 ) ORDER BY id ASC LIMIT 1" Unable to execute statement
[20:22:44.468] ERROR : bool Database::updateSchema(bool*) void Database::populateChildTablesByName(Brewtarget::DBTable) SELECT id FROM fermentable WHERE ( name='Acid Malt'X' AND display=1 ) ORDER BY id ASC LIMIT 1 unrecognized token: "X' AND display=1 ) ORDER BY id ASC LIMIT 1" Unable to execute statement
terminate called after throwing an instance of 'QString'

By changing the SQL statements to escape the name of the record the
issue has been fixed. Fixes issue Brewtarget#319.
mordante added a commit to mordante/brewtarget that referenced this issue Sep 17, 2016
While working on issue Brewtarget#319 the application terminated with the following
error message on the console:
terminate called after throwing an instance of 'QString'

Instead of logging this message on the console show a message box to the
user with the contests of the QString thrown. Do the same for
std::exceptions, and a generic message if the exception is of another
type.
@mikfire
Copy link
Contributor

mikfire commented Nov 1, 2016

The two referenced pull requests have been merged. Can this issue be closed?

@mordante
Copy link
Author

mordante commented Nov 2, 2016

Yes I can't recall other issues, else I'll file a new bug report or pull request.

@mordante mordante closed this as completed Nov 2, 2016
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