From: scottmk Date: Mon, 7 Jun 2010 19:31:05 +0000 (+0000) Subject: Add the left_operand column to the query.expr_xbet view X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=58a045a2ced7e91c4510c078133507a2bd01dd8e;p=evergreen%2Fbjwebb.git Add the left_operand column to the query.expr_xbet view (correcting an oversight). M Open-ILS/src/sql/Pg/002.schema.config.sql M Open-ILS/src/sql/Pg/008.schema.query.sql A Open-ILS/src/sql/Pg/upgrade/0298.schema.xbet-left-operand.sql M Open-ILS/examples/fm_IDL.xml git-svn-id: svn://svn.open-ils.org/ILS/trunk@16619 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index e3470b771..d36d424b9 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -6988,10 +6988,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 93f25a60d..f32fa5ab5 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -65,7 +65,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0297'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0298'); -- Scott McKellar CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/008.schema.query.sql b/Open-ILS/src/sql/Pg/008.schema.query.sql index 420b59e12..f3a19affc 100644 --- a/Open-ILS/src/sql/Pg/008.schema.query.sql +++ b/Open-ILS/src/sql/Pg/008.schema.query.sql @@ -284,6 +284,7 @@ CREATE OR REPLACE VIEW query.expr_xbet AS parenthesize, parent_expr, seq_no, + left_operand, negate FROM query.expression @@ -299,6 +300,7 @@ CREATE OR REPLACE RULE query_expr_xbet_insert_rule AS parenthesize, parent_expr, seq_no, + left_operand, negate ) VALUES ( COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)), @@ -306,6 +308,7 @@ CREATE OR REPLACE RULE query_expr_xbet_insert_rule AS COALESCE(NEW.parenthesize, FALSE), NEW.parent_expr, COALESCE(NEW.seq_no, 1), + NEW.left_operand, COALESCE(NEW.negate, false) ); @@ -317,6 +320,7 @@ CREATE OR REPLACE RULE query_expr_xbet_update_rule AS parenthesize = NEW.parenthesize, parent_expr = NEW.parent_expr, seq_no = NEW.seq_no, + left_operand = NEW.left_operand, negate = NEW.negate WHERE id = OLD.id; diff --git a/Open-ILS/src/sql/Pg/upgrade/0298.schema.xbet-left-operand.sql b/Open-ILS/src/sql/Pg/upgrade/0298.schema.xbet-left-operand.sql new file mode 100644 index 000000000..4a151034c --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0298.schema.xbet-left-operand.sql @@ -0,0 +1,61 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0298'); -- Scott McKellar + +-- Create updatable view for BETWEEN expressions + +DROP VIEW query.expr_xbet CASCADE; + +CREATE OR REPLACE VIEW query.expr_xbet AS + SELECT + id, + parenthesize, + parent_expr, + seq_no, + left_operand, + negate + FROM + query.expression + WHERE + type = 'xbet'; + +CREATE OR REPLACE RULE query_expr_xbet_insert_rule AS + ON INSERT TO query.expr_xbet + DO INSTEAD + INSERT INTO query.expression ( + id, + type, + parenthesize, + parent_expr, + seq_no, + left_operand, + negate + ) VALUES ( + COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)), + 'xbet', + COALESCE(NEW.parenthesize, FALSE), + NEW.parent_expr, + COALESCE(NEW.seq_no, 1), + NEW.left_operand, + COALESCE(NEW.negate, false) + ); + +CREATE OR REPLACE RULE query_expr_xbet_update_rule AS + ON UPDATE TO query.expr_xbet + DO INSTEAD + UPDATE query.expression SET + id = NEW.id, + parenthesize = NEW.parenthesize, + parent_expr = NEW.parent_expr, + seq_no = NEW.seq_no, + left_operand = NEW.left_operand, + negate = NEW.negate + WHERE + id = OLD.id; + +CREATE OR REPLACE RULE query_expr_xbet_delete_rule AS + ON DELETE TO query.expr_xbet + DO INSTEAD + DELETE FROM query.expression WHERE id = OLD.id; + +COMMIT;