Merge lp:~jml/pkgme-devportal/uniqueness-constraint into lp:pkgme-devportal

Proposed by Jonathan Lange
Status: Rejected
Rejected by: James Westby
Proposed branch: lp:~jml/pkgme-devportal/uniqueness-constraint
Merge into: lp:pkgme-devportal
Diff against target: 39 lines (+10/-4)
2 files modified
db/patch-00001.sql (+7/-0)
devportalbinary/tests/test_database.py (+3/-4)
To merge this branch: bzr merge lp:~jml/pkgme-devportal/uniqueness-constraint
Reviewer Review Type Date Requested Status
James Westby Needs Information
Review via email: mp+120206@code.launchpad.net

Commit message

Relax the uniqueness constraint to include architecture.

Description of the change

This relaxes the uniqueness constraint so that when we rollout a patch
that populates architecture, we will be able to add the same dependency
for multiple architectures.

Oh, I'm not convinced that landing this is a good idea, so please don't Approve it without discussing with me.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

  1. If this is going in the patch-00001.sql file then we want to land it before applying that patch?
  2. What makes you think this isn't a good idea.
  3. Perhaps we want a XFAIL test for now?
  4. In fact I'm not sure why the test passes? Is NULL always considered unique?

Thanks,

James

review: Needs Information
Revision history for this message
Jonathan Lange (jml) wrote :

On 22 August 2012 19:45, James Westby <email address hidden> wrote:
> Review: Needs Information
>
> Hi,
>
> 1. If this is going in the patch-00001.sql file then we want to land it before applying that patch?

Yes. I don't think it really matters though, as could easily make this
patch-00002.

> 2. What makes you think this isn't a good idea.

See below.

> 3. Perhaps we want a XFAIL test for now?

I'm not sure, tbh.

> 4. In fact I'm not sure why the test passes? Is NULL always considered unique?

Yes. That's what got me. Specifically (a, b, c, NULL) is considered
not equal to (a, b, c, NULL) for the purposes of uniqueness, even
though (a, b, c) _is_ considered equal to (a, b, c).

I don't currently see a path forward that doesn't involve potential
data corruption or downtime.

jml

Revision history for this message
James Westby (james-w) wrote :

We decided not to do this as part of the first patch, and the second patch
makes it slightly different.

Thanks,

James

Unmerged revisions

84. By Jonathan Lange

Flakes

83. By Jonathan Lange

Update the uniqueness constraints. Change the expected behaviour for double inserts.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'db/patch-00001.sql'
2--- db/patch-00001.sql 2012-08-16 10:09:58 +0000
3+++ db/patch-00001.sql 2012-08-17 17:19:18 +0000
4@@ -1,3 +1,10 @@
5
6 ALTER TABLE libdep
7 ADD COLUMN architecture TEXT;
8+
9+ALTER TABLE libdep
10+ DROP CONSTRAINT libdep_uniq;
11+
12+ALTER TABLE libdep
13+ ADD CONSTRAINT libdep_uniq
14+ UNIQUE (source_package_name, library, dependency, architecture);
15
16=== modified file 'devportalbinary/tests/test_database.py'
17--- devportalbinary/tests/test_database.py 2012-07-26 17:51:15 +0000
18+++ devportalbinary/tests/test_database.py 2012-08-17 17:19:18 +0000
19@@ -3,7 +3,6 @@
20 from fixtures import (
21 TempDir,
22 )
23-from storm.databases.postgres import psycopg2
24 from testresources import ResourcedTestCase
25 from testtools import TestCase
26 from testtools.matchers import (
27@@ -53,9 +52,9 @@
28 def test_double_insert(self):
29 db = self.get_package_db()
30 db.insert_new_library('foo-src', 'libfoo.so.0', 'foo')
31- self.assertRaises(
32- psycopg2.IntegrityError,
33- db.insert_new_library, 'foo-src', 'libfoo.so.0', 'foo')
34+ db.insert_new_library('foo-src', 'libfoo.so.0', 'foo')
35+ deps = db.get_dependencies('libfoo.so.0')
36+ self.assertEqual(deps, set(['foo']))
37
38 def test_differing_dependencies(self):
39 db = self.get_package_db()

Subscribers

People subscribed via source and target branches