[open-ils-commits] r16414 - 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
Mon May 10 15:48:20 EDT 2010
Author: scottmk
Date: 2010-05-10 15:48:15 -0400 (Mon, 10 May 2010)
New Revision: 16414
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0256.schema.query-bind-expr-view.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:
Define an updatable view query.expr_xbind as those rows in
query.expression where type = 'xbind'.
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/0256.schema.query-bind-expr-view.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-10 18:42:52 UTC (rev 16413)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2010-05-10 19:48:15 UTC (rev 16414)
@@ -6727,6 +6727,22 @@
</permacrud>
</class>
+ <class id="xbind" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::expr_xbind" oils_persist:tablename="query.expr_xbind" reporter:label="Bind Variable 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="Bind Variable" name="bind_variable" reporter:datatype="link"/>
+ </fields>
+ <links>
+ <link field="parent_expr" reltype="has_a" key="id" map="" class="qxp"/>
+ <link field="bind_variable" reltype="has_a" key="name" map="" class="qbv"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ </permacrud>
+ </class>
+
<class id="xbool" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::expr_xbool" oils_persist:tablename="query.expr_xbool" reporter:label="Boolean 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-10 18:42:52 UTC (rev 16413)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-05-10 19:48:15 UTC (rev 16414)
@@ -65,7 +65,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0255'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0256'); -- 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-10 18:42:52 UTC (rev 16413)
+++ trunk/Open-ILS/src/sql/Pg/008.schema.query.sql 2010-05-10 19:48:15 UTC (rev 16414)
@@ -323,6 +323,106 @@
DO INSTEAD
DELETE FROM query.expression WHERE id = OLD.id;
+-- Create updatable view for bind variable expressions
+
+CREATE OR REPLACE VIEW query.expr_xbind AS
+ SELECT
+ id,
+ parenthesize,
+ parent_expr,
+ seq_no,
+ bind_variable
+ FROM
+ query.expression
+ WHERE
+ type = 'xbind';
+
+CREATE OR REPLACE RULE query_expr_xbind_insert_rule AS
+ ON INSERT TO query.expr_xbind
+ DO INSTEAD
+ INSERT INTO query.expression (
+ id,
+ type,
+ parenthesize,
+ parent_expr,
+ seq_no,
+ bind_variable
+ ) VALUES (
+ COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)),
+ 'xbind',
+ COALESCE(NEW.parenthesize, FALSE),
+ NEW.parent_expr,
+ COALESCE(NEW.seq_no, 1),
+ NEW.bind_variable
+ );
+
+CREATE OR REPLACE RULE query_expr_xbind_update_rule AS
+ ON UPDATE TO query.expr_xbind
+ DO INSTEAD
+ UPDATE query.expression SET
+ id = NEW.id,
+ parenthesize = NEW.parenthesize,
+ parent_expr = NEW.parent_expr,
+ seq_no = NEW.seq_no,
+ bind_variable = NEW.bind_variable
+ WHERE
+ id = OLD.id;
+
+CREATE OR REPLACE RULE query_expr_xbind_delete_rule AS
+ ON DELETE TO query.expr_xbind
+ DO INSTEAD
+ DELETE FROM query.expression WHERE id = OLD.id;
+
+-- Create updatable view for bind variable expressions
+
+CREATE OR REPLACE VIEW query.expr_xbind AS
+ SELECT
+ id,
+ parenthesize,
+ parent_expr,
+ seq_no,
+ bind_value
+ FROM
+ query.expression
+ WHERE
+ type = 'xbind';
+
+CREATE OR REPLACE RULE query_expr_xbind_insert_rule AS
+ ON INSERT TO query.expr_xbind
+ DO INSTEAD
+ INSERT INTO query.expression (
+ id,
+ type,
+ parenthesize,
+ parent_expr,
+ seq_no,
+ bind_variable
+ ) VALUES (
+ COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)),
+ 'xbind',
+ COALESCE(NEW.parenthesize, FALSE),
+ NEW.parent_expr,
+ COALESCE(NEW.seq_no, 1),
+ NEW.bind_variable
+ );
+
+CREATE OR REPLACE RULE query_expr_xbind_update_rule AS
+ ON UPDATE TO query.expr_xbind
+ DO INSTEAD
+ UPDATE query.expression SET
+ id = NEW.id,
+ parenthesize = NEW.parenthesize,
+ parent_expr = NEW.parent_expr,
+ seq_no = NEW.seq_no,
+ bind_variable = NEW.bind_variable
+ WHERE
+ id = OLD.id;
+
+CREATE OR REPLACE RULE query_expr_xbind_delete_rule AS
+ ON DELETE TO query.expr_xbind
+ DO INSTEAD
+ DELETE FROM query.expression WHERE id = OLD.id;
+
-- Create updatable view for boolean expressions
CREATE OR REPLACE VIEW query.expr_xbool AS
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0256.schema.query-bind-expr-view.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0256.schema.query-bind-expr-view.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0256.schema.query-bind-expr-view.sql 2010-05-10 19:48:15 UTC (rev 16414)
@@ -0,0 +1,55 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0256'); -- Scott McKellar
+
+-- Create updatable view for bind variable expressions
+
+CREATE OR REPLACE VIEW query.expr_xbind AS
+ SELECT
+ id,
+ parenthesize,
+ parent_expr,
+ seq_no,
+ bind_variable
+ FROM
+ query.expression
+ WHERE
+ type = 'xbind';
+
+CREATE OR REPLACE RULE query_expr_xbind_insert_rule AS
+ ON INSERT TO query.expr_xbind
+ DO INSTEAD
+ INSERT INTO query.expression (
+ id,
+ type,
+ parenthesize,
+ parent_expr,
+ seq_no,
+ bind_variable
+ ) VALUES (
+ COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)),
+ 'xbind',
+ COALESCE(NEW.parenthesize, FALSE),
+ NEW.parent_expr,
+ COALESCE(NEW.seq_no, 1),
+ NEW.bind_variable
+ );
+
+CREATE OR REPLACE RULE query_expr_xbind_update_rule AS
+ ON UPDATE TO query.expr_xbind
+ DO INSTEAD
+ UPDATE query.expression SET
+ id = NEW.id,
+ parenthesize = NEW.parenthesize,
+ parent_expr = NEW.parent_expr,
+ seq_no = NEW.seq_no,
+ bind_variable = NEW.bind_variable
+ WHERE
+ id = OLD.id;
+
+CREATE OR REPLACE RULE query_expr_xbind_delete_rule AS
+ ON DELETE TO query.expr_xbind
+ DO INSTEAD
+ DELETE FROM query.expression WHERE id = OLD.id;
+
+COMMIT;
More information about the open-ils-commits
mailing list