After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 729722 - Add support for UNIQUE constraint on columns
Add support for UNIQUE constraint on columns
Status: RESOLVED FIXED
Product: gom
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Gom Maintainers
Gom Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-05-07 15:17 UTC by Mathieu Bridon
Modified: 2014-05-07 15:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gom: Add support for UNIQUE constraint on columns (4.99 KB, patch)
2014-05-07 15:17 UTC, Mathieu Bridon
committed Details | Review
tests: Ensure the UNIQUE constraint works (9.96 KB, patch)
2014-05-07 15:17 UTC, Mathieu Bridon
committed Details | Review
gom: Improve SQLite error reporting (1.06 KB, patch)
2014-05-07 15:17 UTC, Mathieu Bridon
committed Details | Review

Description Mathieu Bridon 2014-05-07 15:17:03 UTC
This is quite a common need for applications, for example to ensure
that no two users have the same email address.

First comit adds support, second commit adds a unit test (in a new test
file which could be reused for testing other constraints).

Last commit improves error reporting, which is quite important when an
insertion into the DB fails because of a violated constraint: you really
want to know which constraint on which column is involved.
Comment 1 Mathieu Bridon 2014-05-07 15:17:07 UTC
Created attachment 276075 [details] [review]
gom: Add support for UNIQUE constraint on columns
Comment 2 Mathieu Bridon 2014-05-07 15:17:12 UTC
Created attachment 276076 [details] [review]
tests: Ensure the UNIQUE constraint works
Comment 3 Mathieu Bridon 2014-05-07 15:17:17 UTC
Created attachment 276077 [details] [review]
gom: Improve SQLite error reporting

Telling the user that a statement failed because:

    Failed to execute statement: 19

is not very useful.

However, this is much better:

    Failed to execute statement: UNIQUE constraint failed: items.email
Comment 4 Bastien Nocera 2014-05-07 15:48:52 UTC
Review of attachment 276075 [details] [review]:

Looks good
Comment 5 Bastien Nocera 2014-05-07 15:51:28 UTC
Attachment 276075 [details] pushed as 9d2d340 - gom: Add support for UNIQUE constraint on columns
Attachment 276076 [details] pushed as 7cc9d67 - tests: Ensure the UNIQUE constraint works
Attachment 276077 [details] pushed as 795fea1 - gom: Improve SQLite error reporting