svn commit: r1856067 [2/2] - in /db/torque/torque4/trunk/torque-templates/src: main/java/org/apache/torque/templates/platform/ main/java/org/apache/torque/templates/transformer/ main/java/org/apache/torque/templates/transformer/sql/ main/java/org/apach...

classic Classic list List threaded Threaded
1 message Options
gk
Reply | Threaded
Open this post in threaded view
|

svn commit: r1856067 [2/2] - in /db/torque/torque4/trunk/torque-templates/src: main/java/org/apache/torque/templates/platform/ main/java/org/apache/torque/templates/transformer/ main/java/org/apache/torque/templates/transformer/sql/ main/java/org/apach...

gk
Added: db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-postgresql.sql
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-postgresql.sql?rev=1856067&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-postgresql.sql (added)
+++ db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-postgresql.sql Fri Mar 22 15:32:47 2019
@@ -0,0 +1,356 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+-- -----------------------------------------------------------------------
+-- postgresql SQL script for schema bookstore
+-- -----------------------------------------------------------------------
+
+
+ALTER TABLE r_ab
+    DROP CONSTRAINT r_ab_FK_1;
+
+
+ALTER TABLE r_ab
+    DROP CONSTRAINT r_ab_FK_2;
+
+
+ALTER TABLE c
+    DROP CONSTRAINT c_FK_1;
+
+
+ALTER TABLE c
+    DROP CONSTRAINT c_FK_2;
+
+
+ALTER TABLE c
+    DROP CONSTRAINT c_FK_3;
+
+
+ALTER TABLE d
+    DROP CONSTRAINT d_FK_1;
+
+
+ALTER TABLE d
+    DROP CONSTRAINT d_FK_2;
+
+
+ALTER TABLE MULTIPK_SELF_REFTABLE
+    DROP CONSTRAINT MULTIPK_SELF_REFTABLE_FK_1;
+
+
+ALTER TABLE ext_schema
+    DROP CONSTRAINT ext_schema_FK_1;
+
+
+ALTER TABLE extext_schema
+    DROP CONSTRAINT extext_schema_FK_1;
+
+
+DROP TABLE a CASCADE;
+DROP SEQUENCE a_SEQ;
+DROP TABLE b CASCADE;
+DROP SEQUENCE b_SEQ;
+DROP TABLE r_ab CASCADE;
+DROP TABLE c CASCADE;
+DROP SEQUENCE c_SEQ;
+DROP TABLE d CASCADE;
+DROP TABLE nopk CASCADE;
+DROP TABLE MULTIPK_SELF_REFTABLE CASCADE;
+DROP TABLE ifc_table CASCADE;
+DROP TABLE ifc_table2 CASCADE;
+DROP TABLE INHERITANCE_TEST CASCADE;
+DROP SEQUENCE INHERITANCE_TEST_SEQ;
+DROP TABLE ext_schema CASCADE;
+DROP SEQUENCE ext_schema_SEQ;
+DROP TABLE extext_schema CASCADE;
+DROP SEQUENCE extext_schema_SEQ;
+DROP TABLE torque.qualified_name CASCADE;
+DROP SEQUENCE torque.qualified_name_SEQ;
+
+DROP SCHEMA torque;
+
+CREATE SCHEMA torque;
+
+-- -----------------------------------------------------------------------
+-- a
+-- -----------------------------------------------------------------------
+CREATE TABLE a
+(
+    a_id INTEGER NOT NULL,
+    name VARCHAR(50) default 'a_name' NOT NULL,
+    contactdata VARCHAR(500) NOT NULL,
+    created_at TIMESTAMP(6) default CURRENT_TIMESTAMP NOT NULL,
+    updated_at TIMESTAMP(6) NOT NULL,
+    enum VARCHAR(50) default 'x',
+    PRIMARY KEY(a_id)
+);
+
+CREATE  INDEX NAME_IDX ON a (name);
+
+CREATE SEQUENCE a_SEQ INCREMENT BY 1 START WITH 1 NO MAXVALUE NO CYCLE;
+
+-- -----------------------------------------------------------------------
+-- b
+-- -----------------------------------------------------------------------
+CREATE TABLE b
+(
+    b_id INTEGER NOT NULL,
+    name VARCHAR(50) NOT NULL,
+    PRIMARY KEY(b_id),
+    CONSTRAINT NAME_UNQ UNIQUE (name)
+);
+
+
+CREATE SEQUENCE b_SEQ INCREMENT BY 1 START WITH 1 NO MAXVALUE NO CYCLE;
+
+-- -----------------------------------------------------------------------
+-- r_ab
+-- -----------------------------------------------------------------------
+CREATE TABLE r_ab
+(
+    a_id INTEGER NOT NULL,
+    b_id INTEGER NOT NULL,
+    name VARCHAR(50) NOT NULL,
+    PRIMARY KEY(a_id, b_id)
+);
+
+
+
+-- -----------------------------------------------------------------------
+-- c
+-- -----------------------------------------------------------------------
+CREATE TABLE c
+(
+    c_id INTEGER NOT NULL,
+    a_id INTEGER NOT NULL,
+    b_id INTEGER NOT NULL,
+    name VARCHAR(50) NOT NULL,
+    PRIMARY KEY(c_id)
+);
+
+
+CREATE SEQUENCE c_SEQ INCREMENT BY 1 START WITH 1 NO MAXVALUE NO CYCLE;
+
+-- -----------------------------------------------------------------------
+-- d
+-- -----------------------------------------------------------------------
+CREATE TABLE d
+(
+    d_id INTEGER NOT NULL,
+    name VARCHAR(255) NOT NULL,
+    b_id INTEGER NOT NULL,
+    a_id INTEGER NOT NULL,
+    PRIMARY KEY(d_id, b_id, a_id)
+);
+
+
+
+-- -----------------------------------------------------------------------
+-- nopk
+-- -----------------------------------------------------------------------
+CREATE TABLE nopk
+(
+    intcol INTEGER,
+    name VARCHAR(50)
+);
+
+
+
+-- -----------------------------------------------------------------------
+-- MULTIPK_SELF_REFTABLE
+-- -----------------------------------------------------------------------
+CREATE TABLE MULTIPK_SELF_REFTABLE
+(
+    COL1 DECIMAL NOT NULL,
+    COL2 DECIMAL NOT NULL,
+    PARENT_COL1 DECIMAL NOT NULL,
+    PARENT_COL2 DECIMAL NOT NULL,
+    PRIMARY KEY(COL1, COL2)
+);
+
+
+
+-- -----------------------------------------------------------------------
+-- ifc_table
+-- -----------------------------------------------------------------------
+CREATE TABLE ifc_table
+(
+    id INTEGER NOT NULL,
+    name VARCHAR(50),
+    PRIMARY KEY(id)
+);
+
+
+
+-- -----------------------------------------------------------------------
+-- ifc_table2
+-- -----------------------------------------------------------------------
+CREATE TABLE ifc_table2
+(
+    id INTEGER NOT NULL,
+    name VARCHAR(50),
+    PRIMARY KEY(id)
+);
+
+
+
+-- -----------------------------------------------------------------------
+-- INHERITANCE_TEST
+-- -----------------------------------------------------------------------
+CREATE TABLE INHERITANCE_TEST
+(
+    INHERITANCE_TEST INTEGER NOT NULL,
+    CLASS_NAME CHAR(1),
+    PAYLOAD_PARENT VARCHAR(100) NOT NULL,
+    PAYLOAD_B VARCHAR(100),
+    PAYLOAD_C VARCHAR(100),
+    PAYLOAD_D VARCHAR(100),
+    PRIMARY KEY(INHERITANCE_TEST)
+);
+
+
+CREATE SEQUENCE INHERITANCE_TEST_SEQ INCREMENT BY 1 START WITH 1 NO MAXVALUE NO CYCLE;
+
+-- -----------------------------------------------------------------------
+-- ext_schema
+-- -----------------------------------------------------------------------
+CREATE TABLE ext_schema
+(
+    ext_schema_id INTEGER NOT NULL,
+    ext_id INTEGER,
+    test INTEGER NOT NULL,
+    PRIMARY KEY(ext_schema_id)
+);
+
+CREATE  INDEX index_ext_id ON ext_schema (ext_id);
+
+CREATE SEQUENCE ext_schema_SEQ INCREMENT BY 1 START WITH 1 NO MAXVALUE NO CYCLE;
+
+-- -----------------------------------------------------------------------
+-- extext_schema
+-- -----------------------------------------------------------------------
+CREATE TABLE extext_schema
+(
+    extext_schema_id INTEGER NOT NULL,
+    extext_id INTEGER,
+    test INTEGER NOT NULL,
+    PRIMARY KEY(extext_schema_id)
+);
+
+
+CREATE SEQUENCE extext_schema_SEQ INCREMENT BY 1 START WITH 1 NO MAXVALUE NO CYCLE;
+
+-- -----------------------------------------------------------------------
+-- torque.qualified_name
+-- -----------------------------------------------------------------------
+CREATE TABLE torque.qualified_name
+(
+    id INTEGER,
+    payload VARCHAR(100)
+);
+
+
+CREATE SEQUENCE torque.qualified_name_SEQ INCREMENT BY 1 START WITH 1 NO MAXVALUE NO CYCLE;
+ALTER TABLE r_ab
+    ADD CONSTRAINT r_ab_FK_1
+    FOREIGN KEY (a_id)
+    REFERENCES a (a_id);
+
+ALTER TABLE r_ab
+    ADD CONSTRAINT r_ab_FK_2
+    FOREIGN KEY (b_id)
+    REFERENCES b (b_id);
+
+ALTER TABLE c
+    ADD CONSTRAINT c_FK_1
+    FOREIGN KEY (a_id, b_id)
+    REFERENCES r_ab (a_id, b_id);
+
+ALTER TABLE c
+    ADD CONSTRAINT c_FK_2
+    FOREIGN KEY (a_id)
+    REFERENCES a (a_id);
+
+ALTER TABLE c
+    ADD CONSTRAINT c_FK_3
+    FOREIGN KEY (b_id)
+    REFERENCES b (b_id);
+
+ALTER TABLE d
+    ADD CONSTRAINT d_FK_1
+    FOREIGN KEY (a_id)
+    REFERENCES a (a_id);
+
+ALTER TABLE d
+    ADD CONSTRAINT d_FK_2
+    FOREIGN KEY (a_id, b_id)
+    REFERENCES r_ab (a_id, b_id);
+
+ALTER TABLE MULTIPK_SELF_REFTABLE
+    ADD CONSTRAINT MULTIPK_SELF_REFTABLE_FK_1
+    FOREIGN KEY (PARENT_COL1, PARENT_COL2)
+    REFERENCES MULTIPK_SELF_REFTABLE (COL1, COL2);
+
+ALTER TABLE ext_schema
+    ADD CONSTRAINT ext_schema_FK_1
+    FOREIGN KEY (ext_id)
+    REFERENCES ext (ext_id);
+
+ALTER TABLE extext_schema
+    ADD CONSTRAINT extext_schema_FK_1
+    FOREIGN KEY (extext_id)
+    REFERENCES extext (extext_id);
+
+ALTER TABLE a
+    ADD CONSTRAINT enum_CHECK
+    CHECK
+    (enum in ('x', 'y', 'z'));
+
+CREATE OR REPLACE VIEW a_b AS
+    SELECT
+    a.a_id AS a_id,
+    a.name AS a_name,
+    b.b_id AS b_id,
+    b.name AS b_name,
+    a.enum AS enum
+    from a join r_ab on a.a_id=r_ab.a_id join b on r_ab.b_id=b.b_id;
+
+COMMENT ON TABLE a IS 'A table';
+
+
+COMMENT ON TABLE b IS 'B table';
+
+
+COMMENT ON TABLE r_ab IS 'r_ab table';
+
+
+COMMENT ON TABLE c IS 'c table contains fk to ar_ab, a and b';
+
+
+COMMENT ON TABLE nopk IS 'this table has no pk';
+
+
+COMMENT ON TABLE ifc_table IS 'this table implements an interface';
+
+
+COMMENT ON TABLE ifc_table2 IS 'this table implements a local interface';
+
+
+COMMENT ON TABLE INHERITANCE_TEST IS 'Table to test inheritance';
+
+
+

Propchange: db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-postgresql.sql
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema.html
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema.html?rev=1856067&r1=1856066&r2=1856067&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema.html (original)
+++ db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema.html Fri Mar 22 15:32:47 2019
@@ -139,6 +139,19 @@ A table
   </tr>
   <tr class="detailrow">
   
+    <td class="detailbackground detailborder detailname notnull" id="acreated_at">created_at
+        </td>
+    <td class="detailbackground detailborder detailtype">java.util.Date</td>
+    <td class="detailbackground detailborder detailsize detailscale"> 6 </td>
+    <td class="detailbackground detailborder detaildefault"> a_name</td>
+    <td class="detailbackground detailborder detailjavaname">CreatedAt</td>
+    <td class="detailbackground detailborder detailpk"><center>  &nbsp; </center></td>
+    <td class="detailbackground detailborder detailfk"><center>  &nbsp; </center></td>
+    <td class="detailbackground detailborder detailnotnull"><center> X </center></td>
+    <td class="detailbackground detailborder detaildescription"> &nbsp;</td>
+  </tr>
+  <tr class="detailrow">
+  
     <td class="detailbackground detailborder detailname" id="aenum">enum
         </td>
     <td class="detailbackground detailborder detailtype">EnumEnum</td>

Modified: db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/jdbc2schema/expected-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/jdbc2schema/expected-schema.xml?rev=1856067&r1=1856066&r2=1856067&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/jdbc2schema/expected-schema.xml (original)
+++ db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/jdbc2schema/expected-schema.xml Fri Mar 22 15:32:47 2019
@@ -17,8 +17,8 @@
   <table name="AUTHOR">
     <column default="GENERATED_BY_DEFAULT" primaryKey="true" name="AUTHOR_ID" type="INTEGER"/>
     <column name="NAME" required="true" type="VARCHAR" size="50"/>
-    <column name="CREATED_AT" type="TIMESTAMP" default="CURRENT_TIMESTAMP"/>
-    <column name="UPDATED_AT" type="TIMESTAMP" default="CURRENT_TIMESTAMP"/>
+    <column name="CREATED_AT" type="TIMESTAMP" default="CURRENT_TIMESTAMP" required="true"/>
+    <column name="UPDATED_AT" type="TIMESTAMP" required="true"/>
   </table>
   <table name="BOOK">
     <column default="GENERATED_BY_DEFAULT" primaryKey="true" name="BOOK_ID" type="INTEGER"/>

Modified: db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/jdbc2schema/jdbc2schemaTest.sql
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/jdbc2schema/jdbc2schemaTest.sql?rev=1856067&r1=1856066&r2=1856067&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/jdbc2schema/jdbc2schemaTest.sql (original)
+++ db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/jdbc2schema/jdbc2schemaTest.sql Fri Mar 22 15:32:47 2019
@@ -42,8 +42,8 @@ CREATE TABLE author
 (
     author_id INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
     name VARCHAR(50) NOT NULL,
-    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
-    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
+    updated_at TIMESTAMP NOT NULL,
     PRIMARY KEY(author_id));
 
 

Modified: db/torque/torque4/trunk/torque-templates/src/test/schema/schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/schema/schema.xml?rev=1856067&r1=1856066&r2=1856067&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/schema/schema.xml (original)
+++ db/torque/torque4/trunk/torque-templates/src/test/schema/schema.xml Fri Mar 22 15:32:47 2019
@@ -44,10 +44,33 @@
       size="50"
       default="a_name"
     />
+     <!--  resetting of attributes size/scale for the same sql type
+     eg. by scale="") is only required if xdoc or html is generated (bug!)
+     -->
+    <column
+      name="contactdata"
+      required="true"
+      type="VARCHAR"
+      size="500"
+    />
+    <column
+      name="created_at"
+      required="true"
+      type="TIMESTAMP"
+      default="CURRENT_TIMESTAMP"
+      scale="6"
+    />
+        <column
+      name="updated_at"
+      required="true"
+      type="TIMESTAMP"
+      scale="6"
+    />
     <column
       name="enum"
       type="VARCHAR"
       size="50"
+      scale=""
       default="x">
       <enum-value value="x"/>
       <enum-value value="y"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]