Skip to content

Commit

Permalink
fix bug in handling nulls in bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
erichanson committed Aug 30, 2017
1 parent 91af015 commit ef5404f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/006-bundle/000-data_model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ create table blob (
value text
);

create function blob_hash_gen_trigger() returns trigger as $$
create or replace function blob_hash_gen_trigger() returns trigger as $$
begin
if NEW.value = NULL then
return NULL;
end if;

NEW.hash = public.digest(NEW.value, 'sha256');
if exists (select 1 from bundle.blob b where b.hash = NEW.hash) then
return NULL;
Expand Down Expand Up @@ -105,7 +109,7 @@ create table rowset_row_field (
id uuid default public.uuid_generate_v4() primary key,
rowset_row_id uuid references rowset_row(id) on delete cascade,
field_id meta.field_id,
value_hash text not null references blob(hash) on delete cascade,
value_hash text references blob(hash) on delete cascade,
unique(rowset_row_id, field_id)
);

Expand Down

0 comments on commit ef5404f

Please sign in to comment.