[Zope-CVS] CVS: Products/Ape/lib/apelib/sql - querygen.py:1.4

Shane Hathaway shane at zope.com
Mon Aug 11 14:56:10 EDT 2003


Update of /cvs-repository/Products/Ape/lib/apelib/sql
In directory cvs.zope.org:/tmp/cvs-serv25481/sql

Modified Files:
	querygen.py 
Log Message:
Added a table_names operation and expanded column_type_translations.

The table_names operation returns a list of all tables in the
database.  The column_type_translations were updated to work better
with the larger number of column types introduced by the experimental
SQLMultiTableProperties code.



=== Products/Ape/lib/apelib/sql/querygen.py 1.3 => 1.4 ===
--- Products/Ape/lib/apelib/sql/querygen.py:1.3	Sun May 18 00:16:29 2003
+++ Products/Ape/lib/apelib/sql/querygen.py	Mon Aug 11 13:56:05 2003
@@ -55,7 +55,7 @@
 
         If the type is unknown, raises KeyError.
         """
-        return self.column_type_translations[column_type]
+        return self.column_type_translations.get(column_type, column_type)
 
 
     def generate(self, operation):
@@ -151,14 +151,18 @@
 class PostgreSQLQueryGenerator (AbstractQueryGenerator):
 
     column_type_translations = {
-        'int':    'int',
         'long':   'bigint',
         'string': 'character varying(255)',
         'blob':   'bytea',
+        'date_international': 'date',
         }
 
     column_name_translations = {}
 
+    def gen_table_names(self):
+        # Returns the names of the tables.
+        return "SELECT tablename FROM pg_tables"
+
     def gen_sequence_check(self):
         return "SELECT last_value FROM %s" % self.table_name
 
@@ -184,15 +188,19 @@
 class MySQLQueryGenerator (AbstractQueryGenerator):
 
     column_type_translations = {
-        'int':    'int',
         'long':   'bigint',
         'string': 'character varying(255)',
         'blob':   'longblob',
+        'date_international': 'date',
         }
 
     column_name_translations = {
         'key': 'objkey',
         }
+
+    def gen_table_names(self):
+        # Returns the names of the tables.
+        return "SHOW TABLES"
 
     def gen_sequence_check(self):
         return "SELECT last_value FROM %s" % self.table_name




More information about the Zope-CVS mailing list