[open-ils-commits] r16395 - in trunk/Open-ILS: examples src/sql/Pg src/sql/Pg/upgrade (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu May 6 12:00:40 EDT 2010


Author: scottmk
Date: 2010-05-06 12:00:37 -0400 (Thu, 06 May 2010)
New Revision: 16395

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0252.schema.query-negation.sql
Modified:
   trunk/Open-ILS/examples/fm_IDL.xml
   trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
   trunk/Open-ILS/src/sql/Pg/008.schema.query.sql
Log:
1. Add a boolean "negate" column to query.expression.

2. Remove the valid values 'xnbet' (for NOT BETWEEN), 'xnex' (for
NOT EXIST) and 'xnin' (for NOT IN) for the column query.expression.type.
We will represent those types with 'xbet', 'xnex', and 'xin',
respectively, combined with negate = TRUE.

3. Eliminate the updatable views defined for the valid values
removed above.

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/0252.schema.query-negation.sql
M    Open-ILS/examples/fm_IDL.xml


Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml	2010-05-06 14:55:11 UTC (rev 16394)
+++ trunk/Open-ILS/examples/fm_IDL.xml	2010-05-06 16:00:37 UTC (rev 16395)
@@ -6594,6 +6594,7 @@
 			<field reporter:label="Function ID" name="function_id" reporter:datatype="link"/>
 			<field reporter:label="Subquery" name="subquery" reporter:datatype="link"/>
 			<field reporter:label="Cast Type" name="cast_type" reporter:datatype="link"/>
+			<field reporter:label="Negate?" name="negate" reporter:datatype="bool"/>
 		</fields>
 		<links>
 			<link field="parent_expr" reltype="has_a" key="id" map="" class="qxp"/>
@@ -6838,52 +6839,6 @@
 		</permacrud>
 	</class>
 
-	<class id="xnbet" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::expr_xnbet" oils_persist:tablename="query.expr_xnbet" reporter:label="Not Between Expression">
-		<fields oils_persist:primary="id" oils_persist:sequence="expression_id_seq">
-			<field reporter:label="Expression ID" name="id" reporter:datatype="id"/>
-			<field reporter:label="Is Parenthesized" name="parenthesize" reporter:datatype="bool"/>
-			<field reporter:label="Parent Expression" name="parent_expr" reporter:datatype="link"/>
-			<field reporter:label="Sequence Number" name="seq_no" reporter:datatype="int"/>
-		</fields>
-		<links>
-			<link field="parent_expr" reltype="might_have" key="id" map="" class="qxp"/>
-		</links>
-		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
-		</permacrud>
-	</class>
-
-	<class id="xnex" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::expr_xnex" oils_persist:tablename="query.expr_xnex" reporter:label="Not Exists Expression">
-		<fields oils_persist:primary="id" oils_persist:sequence="expression_id_seq">
-			<field reporter:label="Expression ID" name="id" reporter:datatype="id"/>
-			<field reporter:label="Is Parenthesized" name="parenthesize" reporter:datatype="bool"/>
-			<field reporter:label="Parent Expression" name="parent_expr" reporter:datatype="link"/>
-			<field reporter:label="Sequence Number" name="seq_no" reporter:datatype="int"/>
-			<field reporter:label="Subquery" name="subquery" reporter:datatype="link"/>
-		</fields>
-		<links>
-			<link field="parent_expr" reltype="might_have" key="id" map="" class="qxp"/>
-			<link field="subquery" reltype="might_have" key="id" map="" class="qsq"/>
-		</links>
-		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
-		</permacrud>
-	</class>
-
-	<class id="xnin" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::expr_xnin" oils_persist:tablename="query.expr_xnin" reporter:label="Not In Expression">
-		<fields oils_persist:primary="id" oils_persist:sequence="expression_id_seq">
-			<field reporter:label="Expression ID" name="id" reporter:datatype="id"/>
-			<field reporter:label="Is Parenthesized" name="parenthesize" reporter:datatype="bool"/>
-			<field reporter:label="Parent Expression" name="parent_expr" reporter:datatype="link"/>
-			<field reporter:label="Sequence Number" name="seq_no" reporter:datatype="int"/>
-			<field reporter:label="Subquery" name="subquery" reporter:datatype="link"/>
-		</fields>
-		<links>
-			<link field="parent_expr" reltype="might_have" key="id" map="" class="qxp"/>
-			<link field="subquery" reltype="might_have" key="id" map="" class="qsq"/>
-		</links>
-		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
-		</permacrud>
-	</class>
-
 	<class id="xnull" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::expr_xnull" oils_persist:tablename="query.expr_xnull" reporter:label="Null Expression">
 		<fields oils_persist:primary="id" oils_persist:sequence="expression_id_seq">
 			<field reporter:label="Expression ID" name="id" reporter:datatype="id"/>

Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-05-06 14:55:11 UTC (rev 16394)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-05-06 16:00:37 UTC (rev 16395)
@@ -65,7 +65,7 @@
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0251'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0252'); -- Scott McKellar
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,

Modified: trunk/Open-ILS/src/sql/Pg/008.schema.query.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/008.schema.query.sql	2010-05-06 14:55:11 UTC (rev 16394)
+++ trunk/Open-ILS/src/sql/Pg/008.schema.query.sql	2010-05-06 16:00:37 UTC (rev 16395)
@@ -123,9 +123,6 @@
 									'xfld',    -- field
 									'xfunc',   -- function
 									'xin',     -- in
-									'xnbet',   -- not between
-	                             	'xnex',    -- not exists
-									'xnin',    -- not in
 	                             	'xnull',   -- null
 									'xnum',    -- number
 									'xop',     -- operator
@@ -150,7 +147,8 @@
 	subquery      INT           REFERENCES query.stored_query
 	                            DEFERRABLE INITIALLY DEFERRED,
 	cast_type     INT           REFERENCES query.datatype
-	                            DEFERRABLE INITIALLY DEFERRED
+	                            DEFERRABLE INITIALLY DEFERRED,
+	negate        BOOL          NOT NULL DEFAULT FALSE
 );
 
 CREATE UNIQUE INDEX query_expr_parent_seq
@@ -717,152 +715,6 @@
     DO INSTEAD
     DELETE FROM query.expression WHERE id = OLD.id;
 
--- Create updatable view for NOT BETWEEN expressions
-
-CREATE OR REPLACE VIEW query.expr_xnbet AS
-    SELECT
-		id,
-		parenthesize,
-		parent_expr,
-		seq_no
-    FROM
-        query.expression
-    WHERE
-        type = 'xnbet';
-
-CREATE OR REPLACE RULE query_expr_xnbet_insert_rule AS
-    ON INSERT TO query.expr_xnbet
-    DO INSTEAD
-    INSERT INTO query.expression (
-		id,
-		type,
-		parenthesize,
-		parent_expr,
-		seq_no
-    ) VALUES (
-        COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)),
-        'xnbet',
-        COALESCE(NEW.parenthesize, FALSE),
-        NEW.parent_expr,
-        COALESCE(NEW.seq_no, 1)
-    );
-
-CREATE OR REPLACE RULE query_expr_xnbet_update_rule AS
-    ON UPDATE TO query.expr_xnbet
-    DO INSTEAD
-    UPDATE query.expression SET
-        id = NEW.id,
-        parenthesize = NEW.parenthesize,
-        parent_expr = NEW.parent_expr,
-        seq_no = NEW.seq_no
-    WHERE
-        id = OLD.id;
-
-CREATE OR REPLACE RULE query_expr_xnbet_delete_rule AS
-    ON DELETE TO query.expr_xnbet
-    DO INSTEAD
-    DELETE FROM query.expression WHERE id = OLD.id;
-
--- Create updatable view for NOT EXISTS expressions
-
-CREATE OR REPLACE VIEW query.expr_xnex AS
-    SELECT
-		id,
-		parenthesize,
-		parent_expr,
-		seq_no,
-		subquery
-    FROM
-        query.expression
-    WHERE
-        type = 'xnex';
-
-CREATE OR REPLACE RULE query_expr_xnex_insert_rule AS
-    ON INSERT TO query.expr_xnex
-    DO INSTEAD
-    INSERT INTO query.expression (
-		id,
-		type,
-		parenthesize,
-		parent_expr,
-		seq_no,
-		subquery
-    ) VALUES (
-        COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)),
-        'xnex',
-        COALESCE(NEW.parenthesize, FALSE),
-        NEW.parent_expr,
-        COALESCE(NEW.seq_no, 1),
-		NEW.subquery
-    );
-
-CREATE OR REPLACE RULE query_expr_xnex_update_rule AS
-    ON UPDATE TO query.expr_xnex
-    DO INSTEAD
-    UPDATE query.expression SET
-        id = NEW.id,
-        parenthesize = NEW.parenthesize,
-        parent_expr = NEW.parent_expr,
-        seq_no = NEW.seq_no,
-		subquery = NEW.subquery
-    WHERE
-        id = OLD.id;
-
-CREATE OR REPLACE RULE query_expr_xnex_delete_rule AS
-    ON DELETE TO query.expr_xnex
-    DO INSTEAD
-    DELETE FROM query.expression WHERE id = OLD.id;
-
--- Create updatable view for NOT IN expressions
-
-CREATE OR REPLACE VIEW query.expr_xnin AS
-    SELECT
-		id,
-		parenthesize,
-		parent_expr,
-		seq_no,
-		subquery
-    FROM
-        query.expression
-    WHERE
-        type = 'xnin';
-
-CREATE OR REPLACE RULE query_expr_xnin_insert_rule AS
-    ON INSERT TO query.expr_xnin
-    DO INSTEAD
-    INSERT INTO query.expression (
-		id,
-		type,
-		parenthesize,
-		parent_expr,
-		seq_no,
-		subquery
-    ) VALUES (
-        COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)),
-        'xnin',
-        COALESCE(NEW.parenthesize, FALSE),
-        NEW.parent_expr,
-        COALESCE(NEW.seq_no, 1),
-		NEW.subquery
-    );
-
-CREATE OR REPLACE RULE query_expr_xnin_update_rule AS
-    ON UPDATE TO query.expr_xnin
-    DO INSTEAD
-    UPDATE query.expression SET
-        id = NEW.id,
-        parenthesize = NEW.parenthesize,
-        parent_expr = NEW.parent_expr,
-        seq_no = NEW.seq_no,
-		subquery = NEW.subquery
-    WHERE
-        id = OLD.id;
-
-CREATE OR REPLACE RULE query_expr_xnin_delete_rule AS
-    ON DELETE TO query.expr_xnin
-    DO INSTEAD
-    DELETE FROM query.expression WHERE id = OLD.id;
-
 -- Create updatable view for NULL expressions
 
 CREATE OR REPLACE VIEW query.expr_xnull AS

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0252.schema.query-negation.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0252.schema.query-negation.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0252.schema.query-negation.sql	2010-05-06 16:00:37 UTC (rev 16395)
@@ -0,0 +1,18 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0252'); -- Scott McKellar
+
+ALTER TABLE query.expression
+	ADD COLUMN negate BOOL NOT NULL DEFAULT FALSE;
+
+COMMIT;
+
+-- The following DROPs will fail if the views being dropped don't exist,
+-- and that's okay.  That's why they're outside of the BEGIN/COMMIT.
+
+DROP VIEW query.expr_xnbet;
+
+DROP VIEW query.expr_xnex;
+
+DROP VIEW query.expr_xnin;
+



More information about the open-ils-commits mailing list