Tag: oo_pqsdbc_01
User: jbu     
Date: 06/05/27 04:33:13

Modified:
 /dba/connectivity/workben/postgresql/
  ddl.py, metadata.py, preparedstatement.py, sdbcx.py, statement.py

Log:
 adjusted tests for postgresql 8.1.x (added with oids clause)

File Changes:

Directory: /dba/connectivity/workben/postgresql/
================================================

File [changed]: ddl.py
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/workben/postgresql/ddl.py?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +16 -11
---------------------
--- ddl.py      22 Jan 2006 15:17:33 -0000      1.1.2.3
+++ ddl.py      27 May 2006 11:33:10 -0000      1.1.2.4
@@ -2,9 +2,9 @@
 #

 #   $RCSfile: ddl.py,v $

 #

-#   $Revision: 1.1.2.3 $

+#   $Revision: 1.1.2.4 $

 #

-#   last change: $Author: jbu $ $Date: 2006/01/22 15:17:33 $

+#   last change: $Author: jbu $ $Date: 2006/05/27 11:33:10 $

 #

 #   The Contents of this file are made available subject to the terms of

 #   either of the following licenses

@@ -108,9 +108,13 @@
     executeIgnoringException( stmt, "DROP TABLE nooid" )

     executeIgnoringException( stmt, "DROP TABLE nooid2" )

     cleanGroupsAndUsers( stmt )

+    executeIgnoringException( stmt, "DROP DOMAIN pqsdbc_short" )

+    executeIgnoringException( stmt, "DROP DOMAIN pqsdbc_amount" )

     

     ddls = (

         "BEGIN",

+       "CREATE DOMAIN pqsdbc_short AS int2",

+        "CREATE DOMAIN pqsdbc_amount AS integer",

         "CREATE USER pqsdbc_joe",

         "CREATE USER pqsdbc_susy",

         "CREATE USER pqsdbc_boss",      

@@ -120,26 +124,27 @@
         "CREATE TABLE customer ( "+

               "id char(8) UNIQUE PRIMARY KEY, "+

               "name text, " +

-              "dummySerial serial UNIQUE) ",

+              "dummySerial serial UNIQUE) WITH OIDS",

         "COMMENT ON TABLE customer IS 'contains customer attributes'",

         "COMMENT ON COLUMN customer.id IS 'unique id'",

         "CREATE TABLE product ("+

              "id char(8) UNIQUE PRIMARY KEY,"+

              "name text,"+

              "price numeric(10,2),"+

-             "image bytea)",

+             "image bytea) WITH OIDS",

         

         "CREATE TABLE ordertab ( "+

              "id char(8) UNIQUE PRIMARY KEY,"+

              "customerid char(8) CONSTRAINT cust REFERENCES customer(id) ON 
DELETE CASCADE ON UPDATE RESTRICT,"+

              "orderdate char(8),"+

-             "delivered boolean )",

+             "delivered boolean ) WITH OIDS",

         "CREATE TABLE orderpos ( "+

              "orderid char(8) REFERENCES ordertab(id),"+

               "id char(3),"+

               "productid char(8) REFERENCES product(id),"+

-              "amount integer,"+

-              "PRIMARY KEY (orderid,id))",

+              "amount pqsdbc_amount,"+

+              "shortamount pqsdbc_short,"+

+              "PRIMARY KEY (orderid,id)) WITH OIDS",

         "CREATE TABLE nooid ("+

              "id char(8) UNIQUE PRIMARY KEY,"+

              "name text) "+

@@ -165,10 +170,10 @@
         "INSERT INTO ordertab VALUES ( '1', 'C2', '20030403','true')",

         "INSERT INTO ordertab VALUES ( '2', 'C1', '20030402','false')",

         

-        "INSERT INTO orderpos VALUES ( '1','001', 'PZZ2',2)",

-        "INSERT INTO orderpos VALUES ( '1','002', 'PZZ5',3)",

-        "INSERT INTO orderpos VALUES ( '2','001', 'PAS1',5)",

-        "INSERT INTO orderpos VALUES ( '2','002', 'PZZ2',3)",

+        "INSERT INTO orderpos VALUES ( '1','001', 'PZZ2',2,0)",

+        "INSERT INTO orderpos VALUES ( '1','002', 'PZZ5',3,-1)",

+        "INSERT INTO orderpos VALUES ( '2','001', 'PAS1',5,1)",

+        "INSERT INTO orderpos VALUES ( '2','002', 'PZZ2',3,2)",

         "COMMIT" )

     for i in ddls:

         stmt.executeUpdate(i)


File [changed]: metadata.py
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/workben/postgresql/metadata.py?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +36 -2
--------------------
--- metadata.py 10 Jun 2004 15:27:15 -0000      1.1.2.3
+++ metadata.py 27 May 2006 11:33:11 -0000      1.1.2.4
@@ -2,9 +2,9 @@
 #

 #   $RCSfile: metadata.py,v $

 #

-#   $Revision: 1.1.2.3 $

+#   $Revision: 1.1.2.4 $

 #

-#   last change: $Author: jbu $ $Date: 2004/06/10 15:27:15 $

+#   last change: $Author: jbu $ $Date: 2006/05/27 11:33:11 $

 #

 #   The Contents of this file are made available subject to the terms of

 #   either of the following licenses

@@ -61,6 +61,8 @@
 import sys

 import ddl

 

+from com.sun.star.sdbc.DataType import SMALLINT, INTEGER, BIGINT , DATE, TIME, 
TIMESTAMP, NUMERIC

+

 def dumpResultSet( rs , count ):

 #    for i in range(1, count):

 #        sys.stdout.write(meta.getColumnName( i ) + "\t")

@@ -77,6 +79,7 @@
 def suite(ctx,dburl):

     suite = unittest.TestSuite()

     suite.addTest(TestCase("testDatabaseMetaData",ctx,dburl))

+    suite.addTest(TestCase("testTypeGuess",ctx,dburl))

     return suite

 

 class TestCase(unittest.TestCase):

@@ -112,6 +115,37 @@
 #          dumpResultSet( rs , 18 )

           rs = meta.getTypeInfo()

 #          dumpResultSet(rs, 18)

+         while rs.next():

+               if rs.getString(1) == "pqsdbc_short":

+                  self.failUnless( rs.getInt(2) == SMALLINT )

+                  break

+          self.failUnless( not rs.isAfterLast() )  # domain type cannot be 
found

+         

               

           rs = meta.getIndexInfo( None, "public" , "customer", False, False )

 #          dumpResultSet( rs, 13 )

+

+      def testTypeGuess( self ):

+          stmt = self.connection.createStatement()

+          rs = stmt.executeQuery( "SELECT sum(amount) FROM orderpos" )

+          meta = rs.getMetaData()

+          self.failUnless( meta.getColumnType(1) == BIGINT )

+

+          stmt = self.connection.createStatement()

+          rs = stmt.executeQuery( "SELECT sum(price) FROM product" )

+          meta = rs.getMetaData()

+          self.failUnless( meta.getColumnType(1) == NUMERIC )

+

+          rs = stmt.executeQuery( "SELECT max(ttime) FROM firsttable" )

+          meta = rs.getMetaData()

+          self.failUnless( meta.getColumnType(1) == TIME )

+

+          rs = stmt.executeQuery( "SELECT max(tdate) FROM firsttable" )

+          meta = rs.getMetaData()

+          self.failUnless( meta.getColumnType(1) == DATE )

+

+          rs = stmt.executeQuery( "SELECT max(ttimestamp) FROM firsttable" )

+          meta = rs.getMetaData()

+          self.failUnless( meta.getColumnType(1) == TIMESTAMP )

+#          rs.next()

+#          print rs.getString( 1 )


File [changed]: preparedstatement.py
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/workben/postgresql/preparedstatement.py?r1=1.1.2.6&r2=1.1.2.7
Delta lines:  +5 -5
-------------------
--- preparedstatement.py        22 Jan 2006 15:17:33 -0000      1.1.2.6
+++ preparedstatement.py        27 May 2006 11:33:11 -0000      1.1.2.7
@@ -2,9 +2,9 @@
 #
 #   $RCSfile: preparedstatement.py,v $
 #
-#   $Revision: 1.1.2.6 $
+#   $Revision: 1.1.2.7 $
 #
-#   last change: $Author: jbu $ $Date: 2006/01/22 15:17:33 $
+#   last change: $Author: jbu $ $Date: 2006/05/27 11:33:11 $
 #
 #   The Contents of this file are made available subject to the terms of
 #   either of the following licenses
@@ -94,9 +94,9 @@
       
       def testQuery( self ):
 
-          stmts = "SELECT product.id WHERE product.price > :lowprice AND 
product.price < :upprice", \
-              "SELECT product.id WHERE product.price > ? AND product.price < 
?" , \
-              "SELECT \"product\".\"id\" WHERE \"product\".\"price\" > 
:lowprice AND \"product\".\"price\" < :upprice"
+          stmts = "SELECT product.id FROM product WHERE product.price > 
:lowprice AND product.price < :upprice", \
+              "SELECT product.id FROM product WHERE product.price > ? AND 
product.price < ?" , \
+              "SELECT \"product\".\"id\" FROM product WHERE 
\"product\".\"price\" > :lowprice AND \"product\".\"price\" < :upprice"
           
 
           for stmt in stmts:

File [changed]: sdbcx.py
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/workben/postgresql/sdbcx.py?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +3 -3
-------------------
--- sdbcx.py    11 Jul 2004 10:06:31 -0000      1.1.2.4
+++ sdbcx.py    27 May 2006 11:33:11 -0000      1.1.2.5
@@ -2,9 +2,9 @@
 #

 #   $RCSfile: sdbcx.py,v $

 #

-#   $Revision: 1.1.2.4 $

+#   $Revision: 1.1.2.5 $

 #

-#   last change: $Author: jbu $ $Date: 2004/07/11 10:06:31 $

+#   last change: $Author: jbu $ $Date: 2006/05/27 11:33:11 $

 #

 #   The Contents of this file are made available subject to the terms of

 #   either of the following licenses

@@ -120,7 +120,7 @@
           self.failUnless( descriptor.Type == type )

           self.failUnless( descriptor.Precision == prec )

           self.failUnless( descriptor.Scale == scale )

-          print descriptor.DefaultValue + " == " + defaultValue 

+#          print descriptor.DefaultValue + " == " + defaultValue 

 #          self.failUnless( descriptor.DefaultValue == defaultValue )

           self.failUnless( descriptor.Description == desc )

           


File [changed]: statement.py
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/workben/postgresql/statement.py?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +4 -3
-------------------
--- statement.py        29 Aug 2004 08:36:40 -0000      1.1.2.4
+++ statement.py        27 May 2006 11:33:11 -0000      1.1.2.5
@@ -2,9 +2,9 @@
 #
 #   $RCSfile: statement.py,v $
 #
-#   $Revision: 1.1.2.4 $
+#   $Revision: 1.1.2.5 $
 #
-#   last change: $Author: jbu $ $Date: 2004/08/29 08:36:40 $
+#   last change: $Author: jbu $ $Date: 2006/05/27 11:33:11 $
 #
 #   The Contents of this file are made available subject to the terms of
 #   either of the following licenses
@@ -121,7 +121,7 @@
           ddls = (
                "BEGIN",
                "CREATE TABLE firsttable (tString text,tInteger integer,tShort 
smallint,tLong bigint,tFloat real,"+
-                       "tDouble double precision,tByteSeq bytea,tBool boolean, 
tDate date, tTime time, tTimestamp timestamp, tIntArray integer[], tStringArray 
text[], tSerial serial )",
+                       "tDouble double precision,tByteSeq bytea,tBool boolean, 
tDate date, tTime time, tTimestamp timestamp, tIntArray integer[], tStringArray 
text[], tSerial serial ) WITH OIDS",
                "INSERT INTO firsttable VALUES ( 'foo', 70000, 12000, 70001, 
2.4, 2.45, 'huhu', 'true',  '1999-01-08','04:05:06','1999-01-08 04:05:06', 
'{2,3,4}', '{\"huhu\",\"hi\"}')",
                "INSERT INTO firsttable VALUES ( 'foo2', 69999, 12001, 70002, 
-2.4, 2.55, 'huhu', 'false', '1999-01-08','04:05:06','1999-01-08 04:05:06', 
NULL , '{\"bla\"}' )",
                "INSERT INTO firsttable VALUES ( 'foo2', 69999, 12001, 70002, 
-2.4, 2.55, 'huhu', null,  '1999-01-08', '04:05:06','1999-01-08 04:05:06', '{}' 
, '{\"bl ubs\",\"bl\\\\\\\\a}}b\\\\\"a\",\"blub\"}' )",
@@ -275,4 +275,5 @@
           self.failUnless( data[0] == myarray[0] )
           self.failUnless( data[1] == myarray[1] )
           self.failUnless( data[2] == myarray[2] )
+          
           




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to