Control: tags -1 + patch

On Sun, Nov 09, 2014 at 08:23:31AM +0100, Lucas Nussbaum wrote:
> >   File "/usr/lib/python2.7/dist-packages/twisted/internet/utils.py", line 
> > 203, in runWithWarningsSuppressed
> >     reraise(exc_info[1], exc_info[2])
> >   File "/usr/lib/python2.7/dist-packages/twisted/internet/utils.py", line 
> > 199, in runWithWarningsSuppressed
> >     result = f(*a, **kw)
> >   File "/«PKGBUILDDIR»/test/test_provider.py", line 193, in 
> > test_populate_db_from_objs
> >     self.provider.populate_networks_from_objs(networks)
> >   File "/«PKGBUILDDIR»/wader/common/provider.py", line 647, in 
> > populate_networks_from_objs
> >     "?,?,?,?,?,?,?,?)", args)
> > IntegrityError: constraint failed

Relevant parts of the schema:

create table network_info(
    id text primary key,
[...]
);

create table apn(
[...]
    network_id integer not null
[...]
);

-- prevent insert on apn with unknown network_id
create trigger fki_apns_with_unknown_network_id before insert on "apn"
    when new."network_id" is not null and not exists (select 1 from 
"network_info" where new."network_id" == "id")
begin
  select raise(abort, 'constraint failed');
end;

Then at least in some of test failures values like '21401' are inserted in 
those columns.
Looks like there are some subtleties when inserting and/or comparing such 
values.

The following patch fixes the problem:

--- wader-0.5.12.orig/wader/common/provider.py
+++ wader-0.5.12/wader/common/provider.py
@@ -187,7 +187,7 @@ create table apn(
     wap_username text,
     wap_password text,
     wap_auth text,
-    network_id integer not null
+    network_id text not null
         constraint fk_mi_network_id references network_info(id) on delete 
cascade);
 
 create table sources_info (


-- 
WBR, wRAR

Attachment: signature.asc
Description: Digital signature

Reply via email to