Define an updatable view query.expr_xbind as those rows in
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 10 May 2010 19:48:15 +0000 (19:48 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 10 May 2010 19:48:15 +0000 (19:48 +0000)
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

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16414 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/008.schema.query.sql
Open-ILS/src/sql/Pg/upgrade/0256.schema.query-bind-expr-view.sql [new file with mode: 0644]

index cf889ea..3f61007 100644 (file)
@@ -6727,6 +6727,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </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"/>
index fc1a1d9..432719a 100644 (file)
@@ -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 ('0255'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0256'); -- Scott McKellar
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index bf96b8d..6749497 100644 (file)
@@ -323,6 +323,106 @@ CREATE OR REPLACE RULE query_expr_xbet_delete_rule AS
     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
diff --git a/Open-ILS/src/sql/Pg/upgrade/0256.schema.query-bind-expr-view.sql b/Open-ILS/src/sql/Pg/upgrade/0256.schema.query-bind-expr-view.sql
new file mode 100644 (file)
index 0000000..c49d316
--- /dev/null
@@ -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;