[open-ils-commits] r15049 - 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 Nov 30 16:52:51 EST 2009
Author: scottmk
Date: 2009-11-30 16:52:46 -0500 (Mon, 30 Nov 2009)
New Revision: 15049
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0099.schema.expression.sql
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
Log:
Add table query.expression, and add a couple of foreign keys
that point to it.
M Open-ILS/src/sql/Pg/002.schema.config.sql
A Open-ILS/src/sql/Pg/upgrade/0099.schema.expression.sql
M Open-ILS/examples/fm_IDL.xml
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2009-11-30 20:36:13 UTC (rev 15048)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2009-11-30 21:52:46 UTC (rev 15049)
@@ -5421,6 +5421,35 @@
</permacrud>
</class>
+ <class id="qxp" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::expression" oils_persist:tablename="query.expression" reporter:label="Expression">
+ <fields oils_persist:primary="id" oils_persist:sequence="">
+ <field reporter:label="Expression ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Expression Type" name="type" reporter:datatype="text"/>
+ <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="Literal" name="literal" reporter:datatype="text"/>
+ <field reporter:label="Table Alias" name="table_alias" reporter:datatype="text"/>
+ <field reporter:label="Column Name" name="column_name" reporter:datatype="text"/>
+ <field reporter:label="Left Operand" name="left_operand" reporter:datatype="link"/>
+ <field reporter:label="Operator" name="operator" reporter:datatype="text"/>
+ <field reporter:label="Right Operand" name="right_operand" reporter:datatype="link"/>
+ <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"/>
+ </fields>
+ <links>
+ <link field="parent_expr" reltype="might_have" key="id" map="" class="qxp"/>
+ <link field="left_operand" reltype="might_have" key="id" map="" class="qxp"/>
+ <link field="right_operand" reltype="might_have" key="id" map="" class="qxp"/>
+ <link field="function_id" reltype="might_have" key="id" map="" class="qfs"/>
+ <link field="subquery" reltype="might_have" key="id" map="" class="qsq"/>
+ <link field="cast_type" reltype="might_have" key="id" map="" class="qdt"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ </permacrud>
+ </class>
+
<!-- ********************************************************************************************************************* -->
<!-- What follows is a set of example extensions that are useful for PINES. Comment out or remove if you don't want them. -->
<!-- ********************************************************************************************************************* -->
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-11-30 20:36:13 UTC (rev 15048)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-11-30 21:52:46 UTC (rev 15049)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0098'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0099'); -- Scott McKellar
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0099.schema.expression.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0099.schema.expression.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0099.schema.expression.sql 2009-11-30 21:52:46 UTC (rev 15049)
@@ -0,0 +1,65 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0099'); -- Scott McKellar
+
+CREATE TABLE query.expression (
+ id SERIAL PRIMARY KEY,
+ type TEXT NOT NULL CONSTRAINT predicate_type CHECK
+ ( type IN (
+ 'xbet', -- between
+ 'xbool', -- boolean
+ 'xcase', -- case
+ 'xcast', -- cast
+ 'xcol', -- column
+ 'xex', -- exists
+ 'xfld', -- field
+ 'xfunc', -- function
+ 'xin', -- in
+ 'xnbet', -- not between
+ 'xnex', -- not exists
+ 'xnin', -- not in
+ 'xnull', -- null
+ 'xnum', -- number
+ 'xop', -- operator
+ 'xstr', -- string
+ 'xsubq' -- subquery
+ ) ),
+ parenthesize BOOL NOT NULL DEFAULT FALSE,
+ parent_expr INT REFERENCES query.expression
+ ON DELETE CASCADE
+ DEFERRABLE INITIALLY DEFERRED,
+ seq_no INT NOT NULL DEFAULT 1,
+ literal TEXT,
+ table_alias TEXT,
+ column_name TEXT,
+ left_operand INT REFERENCES query.expression
+ DEFERRABLE INITIALLY DEFERRED,
+ operator TEXT,
+ right_operand INT REFERENCES query.expression
+ DEFERRABLE INITIALLY DEFERRED,
+ function_id INT REFERENCES query.function_sig
+ DEFERRABLE INITIALLY DEFERRED,
+ subquery INT REFERENCES query.stored_query
+ DEFERRABLE INITIALLY DEFERRED,
+ cast_type INT REFERENCES query.datatype
+ DEFERRABLE INITIALLY DEFERRED
+);
+
+CREATE UNIQUE INDEX query_expr_parent_seq
+ ON query.expression( parent_expr, seq_no )
+ WHERE parent_expr IS NOT NULL;
+
+-- Due to some circular references, the following foreign key definitions
+-- had to be deferred until query.expression existed:
+
+ALTER TABLE query.stored_query
+ ADD FOREIGN KEY ( where_clause )
+ REFERENCES query.expression( id )
+ DEFERRABLE INITIALLY DEFERRED;
+
+ALTER TABLE query.stored_query
+ ADD FOREIGN KEY ( having_clause )
+ REFERENCES query.expression( id )
+ DEFERRABLE INITIALLY DEFERRED;
+
+COMMIT;
More information about the open-ils-commits
mailing list