[gnue] r9779 - in trunk/gnue-common/src/datasources/drivers: DBSIG2 sql/postgresql

[email protected]
Newsgroups gmane.comp.cms.gnue.cvs
Message-ID <[email protected]>
Author: johannes
Date: 2007-09-20 06:57:09 -0500 (Thu, 20 Sep 2007)
New Revision: 9779

Modified:
   trunk/gnue-common/src/datasources/drivers/DBSIG2/Behavior.py
   trunk/gnue-common/src/datasources/drivers/sql/postgresql/Behavior.py
Log:
Take the config paramater 'use_oid' into account when creating new 
tables on PostgreSQL 8.1+ (where oid's are off by default)


Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/Behavior.py	2007-08-24 08:18:08 UTC (rev 9778)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/Behavior.py	2007-09-20 11:57:09 UTC (rev 9779)
@@ -188,9 +188,11 @@
         triple = self._extraPrimaryKey_ and result or fcode
         self._mergeTriple (triple, self._createPrimaryKey_ (pkey))
 
-      code = u"CREATE TABLE %s (%s)" % (table.name, ", ".join (fcode [1]))
-      self._mergeTriple (result, (fcode [0], [code], fcode [2]))
+      code = u"CREATE TABLE %s (%s) %s" % (table.name, ", ".join (fcode [1]),
+              self._create_table_trailer_(table))
 
+      self._mergeTriple (result, (fcode [0], [code.strip()], fcode [2]))
+
     # build all indices
     for index in table.findChildrenOfType ('GSIndex', False, True):
       if index._action == 'add':
@@ -209,6 +211,21 @@
 
 
   # ---------------------------------------------------------------------------
+  # Create trailing code for a CREATE TABLE statement
+  # ---------------------------------------------------------------------------
+
+  def _create_table_trailer_(self, table):
+    """
+    Create trailing SQL code for building a table.  This can be overriden by
+    descendants
+
+    @param table: GSTable instance to create code for.
+    @returns: String with code to be added
+    """
+    return ""
+
+
+  # ---------------------------------------------------------------------------
   # Create a fields sequence for the given item
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-common/src/datasources/drivers/sql/postgresql/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/postgresql/Behavior.py	2007-08-24 08:18:08 UTC (rev 9778)
+++ trunk/gnue-common/src/datasources/drivers/sql/postgresql/Behavior.py	2007-09-20 11:57:09 UTC (rev 9779)
@@ -428,3 +428,15 @@
 
     elif field.defaultwith == 'timestamp':
       field.default = "DEFAULT now()"
+
+
+  # ---------------------------------------------------------------------------
+  # If we're using OIDs extend the table creation statement
+  # ---------------------------------------------------------------------------
+
+  def _create_table_trailer_(self, table):
+
+    if self.__connection.parameters.get('use_oid', False):
+      return "WITH OIDS"
+    else:
+      return ""
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.