Add to query.expression: foreign key bind_variable pointing
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 10 May 2010 18:42:52 +0000 (18:42 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 10 May 2010 18:42:52 +0000 (18:42 +0000)
to query.bind_variable.  Also: allow the expression 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/0255.query-expr-bind.sql
M    Open-ILS/examples/fm_IDL.xml

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16413 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/0255.query-expr-bind.sql [new file with mode: 0644]

index 1b01838..cf889ea 100644 (file)
@@ -6608,6 +6608,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <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"/>
+                       <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"/>
@@ -6616,6 +6617,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="function_id" reltype="has_a" key="id" map="" class="qfs"/>
                        <link field="subquery" reltype="has_a" key="id" map="" class="qsq"/>
                        <link field="cast_type" reltype="has_a" key="id" map="" class="qdt"/>
+                       <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>
index 0981b78..fc1a1d9 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 ('0254'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0255'); -- Scott McKellar
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index cfa921e..bf96b8d 100644 (file)
@@ -121,9 +121,10 @@ CREATE TABLE query.bind_variable (
 
 CREATE TABLE query.expression (
        id            SERIAL        PRIMARY KEY,
-       type          TEXT          NOT NULL CONSTRAINT predicate_type CHECK
+       type          TEXT          NOT NULL CONSTRAINT expression_type CHECK
                                    ( type IN (
                                        'xbet',    -- between
+                                                                       'xbind',   -- bind variable
                                                                        'xbool',   -- boolean
                                        'xcase',   -- case
                                                                        'xcast',   -- cast
@@ -157,7 +158,9 @@ CREATE TABLE query.expression (
                                    DEFERRABLE INITIALLY DEFERRED,
        cast_type     INT           REFERENCES query.datatype
                                    DEFERRABLE INITIALLY DEFERRED,
-       negate        BOOL          NOT NULL DEFAULT FALSE
+       negate        BOOL          NOT NULL DEFAULT FALSE,
+       bind_variable TEXT          REFERENCES query.bind_variable
+                                   DEFERRABLE INITIALLY DEFERRED
 );
 
 CREATE UNIQUE INDEX query_expr_parent_seq
diff --git a/Open-ILS/src/sql/Pg/upgrade/0255.query-expr-bind.sql b/Open-ILS/src/sql/Pg/upgrade/0255.query-expr-bind.sql
new file mode 100644 (file)
index 0000000..c9edc69
--- /dev/null
@@ -0,0 +1,33 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0255'); -- Scott McKellar
+
+ALTER TABLE query.expression
+    ADD CONSTRAINT expression_type CHECK
+        ( type IN (
+            'xbet',
+            'xbind',
+            'xbool',
+            'xcase',
+            'xcast',
+            'xcol',
+            'xex',
+            'xfld',
+            'xfunc',
+            'xin',
+            'xnull',
+            'xnum',
+            'xop',
+            'xstr',
+            'xsubq'
+));
+
+ALTER TABLE query.expression
+       DROP CONSTRAINT predicate_type;
+
+ALTER TABLE query.expression
+       ADD COLUMN bind_variable TEXT
+               REFERENCES query.bind_variable
+               DEFERRABLE INITIALLY DEFERRED;
+
+COMMIT;