BEGIN; SELECT plan(3); INSERT INTO config.org_unit_setting_type (name, label) VALUES ('foo', 'Turn on foo'); INSERT INTO config.org_unit_setting_type (name, label) VALUES ('bar', 'Turn on bar'); INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (1, 'foo', '"foo 1"'); INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (2, 'foo', '"foo 2"'); INSERT INTO actor.org_unit_setting (org_unit, name, value) VALUES (2, 'bar', '"bar 2"'); SELECT results_eq( $$ SELECT name, value FROM actor.org_unit_ancestor_setting_batch(1, '{foo,bar}') $$, $$ VALUES ('foo', '"foo 1"') $$, 'can retrieve batch of org unit settings' ); SELECT results_eq( $$ SELECT name, value FROM actor.org_unit_ancestor_setting_batch(2, '{foo,bar}') $$, $$ VALUES ('foo', '"foo 2"'), ('bar', '"bar 2"') $$, 'can retrieve batch of org unit settings at lower level' ); DELETE FROM actor.org_unit_setting WHERE name = 'foo' AND org_unit = 2; SELECT results_eq( $$ SELECT name, value FROM actor.org_unit_ancestor_setting_batch(2, '{foo,bar}') $$, $$ VALUES ('foo', '"foo 1"'), ('bar', '"bar 2"') $$, 'can retrieve batch of org unit settings with fallback' ); ROLLBACK;