Project

General

Profile

« Previous | Next » 

Revision 11908

bugfix: schemas/vegbien.sql: location: use the place_id from the parent location when no place_id is specified. this fixes a bug in analytical_stem_view where the parent location's place_id was used because it was sometimes missing from the sublocation, but the parent place_id itself was sometimes missing instead if sublocations each had their own place information. this way, it is always available directly in the sublocation, populated from the parent location if needed.

View differences:

schemas/vegbien.my.sql
409 409

  
410 410

  
411 411
--
412
-- Name: location__pull_forward_from_parent(); Type: FUNCTION; Schema: public; Owner: -
413
--
414

  
415

  
416

  
417

  
418
--
419
-- Name: FUNCTION location__pull_forward_from_parent(); Type: COMMENT; Schema: public; Owner: -
420
--
421

  
422

  
423

  
424

  
425
--
412 426
-- Name: locationevent__communities(int(11)); Type: FUNCTION; Schema: public; Owner: -
413 427
--
414 428

  
......
7816 7830

  
7817 7831

  
7818 7832
--
7833
-- Name: location__pull_forward_from_parent; Type: TRIGGER; Schema: public; Owner: -
7834
--
7835

  
7836

  
7837

  
7838

  
7839
--
7819 7840
-- Name: locationevent__pull_forward_from_parent; Type: TRIGGER; Schema: public; Owner: -
7820 7841
--
7821 7842

  
schemas/vegbien.sql
796 796

  
797 797

  
798 798
--
799
-- Name: location__pull_forward_from_parent(); Type: FUNCTION; Schema: public; Owner: -
800
--
801

  
802
CREATE FUNCTION location__pull_forward_from_parent() RETURNS trigger
803
    LANGUAGE plpgsql
804
    AS $$
805
DECLARE
806
	parent location;
807
BEGIN
808
	SELECT * INTO parent FROM location WHERE location_id = new.parent_id;
809
	
810
	IF new.place_id IS NULL THEN new.place_id = parent.place_id; END IF;
811
	
812
	RETURN new;
813
END;
814
$$;
815

  
816

  
817
--
818
-- Name: FUNCTION location__pull_forward_from_parent(); Type: COMMENT; Schema: public; Owner: -
819
--
820

  
821
COMMENT ON FUNCTION location__pull_forward_from_parent() IS 'see wiki.vegpath.org/Pull-forward';
822

  
823

  
824
--
799 825
-- Name: locationevent__communities(integer); Type: FUNCTION; Schema: public; Owner: -
800 826
--
801 827

  
......
9407 9433

  
9408 9434

  
9409 9435
--
9436
-- Name: location__pull_forward_from_parent; Type: TRIGGER; Schema: public; Owner: -
9437
--
9438

  
9439
CREATE TRIGGER location__pull_forward_from_parent BEFORE INSERT OR UPDATE OF location_id, parent_id ON location FOR EACH ROW WHEN ((new.parent_id IS NOT NULL)) EXECUTE PROCEDURE location__pull_forward_from_parent();
9440

  
9441

  
9442
--
9410 9443
-- Name: locationevent__pull_forward_from_parent; Type: TRIGGER; Schema: public; Owner: -
9411 9444
--
9412 9445

  

Also available in: Unified diff