From 2959729fe6fc075417d09e44b569c81bda52bb73 Mon Sep 17 00:00:00 2001 From: scottmk Date: Fri, 11 Jun 2010 13:01:54 +0000 Subject: [PATCH] Add column "left_operand" to query.expr_xcase view. 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/0304.schema.query-expr-xcase-left-operand.sql M Open-ILS/examples/fm_IDL.xml git-svn-id: svn://svn.open-ils.org/ILS/trunk@16674 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 2 + Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/008.schema.query.sql | 4 ++ ...4.schema.query-expr-xcase-left-operand.sql | 62 +++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0304.schema.query-expr-xcase-left-operand.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index dbdc960bc9..ff06baf468 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -7039,10 +7039,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 20ab9cd189..bd03c244ec 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -68,7 +68,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0303'); -- phasefx +INSERT INTO config.upgrade_log (version) VALUES ('0304'); -- 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 f3a19affc5..2d2ef4dbb4 100644 --- a/Open-ILS/src/sql/Pg/008.schema.query.sql +++ b/Open-ILS/src/sql/Pg/008.schema.query.sql @@ -442,6 +442,7 @@ CREATE OR REPLACE VIEW query.expr_xcase AS parenthesize, parent_expr, seq_no, + left_operand, negate FROM query.expression @@ -457,6 +458,7 @@ CREATE OR REPLACE RULE query_expr_xcase_insert_rule AS parenthesize, parent_expr, seq_no, + left_operand, negate ) VALUES ( COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)), @@ -464,6 +466,7 @@ CREATE OR REPLACE RULE query_expr_xcase_insert_rule AS COALESCE(NEW.parenthesize, FALSE), NEW.parent_expr, COALESCE(NEW.seq_no, 1), + NEW.left_operand, COALESCE(NEW.negate, false) ); @@ -475,6 +478,7 @@ CREATE OR REPLACE RULE query_expr_xcase_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/0304.schema.query-expr-xcase-left-operand.sql b/Open-ILS/src/sql/Pg/upgrade/0304.schema.query-expr-xcase-left-operand.sql new file mode 100644 index 0000000000..7663529902 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0304.schema.query-expr-xcase-left-operand.sql @@ -0,0 +1,62 @@ +-- Add left_operand column to query.expr_xcase view + +-- If the view doesn't exist, this drop will fail, and that's okay +DROP VIEW query.expr_xcase CASCADE; + +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0304'); -- Scott McKellar + +CREATE OR REPLACE VIEW query.expr_xcase AS + SELECT + id, + parenthesize, + parent_expr, + seq_no, + left_operand, + negate + FROM + query.expression + WHERE + type = 'xcase'; + +CREATE OR REPLACE RULE query_expr_xcase_insert_rule AS + ON INSERT TO query.expr_xcase + 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)), + 'xcase', + 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_xcase_update_rule AS + ON UPDATE TO query.expr_xcase + 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_xcase_delete_rule AS + ON DELETE TO query.expr_xcase + DO INSTEAD + DELETE FROM query.expression WHERE id = OLD.id; + +COMMIT; -- 2.43.2