[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5816 - trunk/gnue-common/src/schema/scripter/processors
From: |
johannes |
Subject: |
r5816 - trunk/gnue-common/src/schema/scripter/processors |
Date: |
Fri, 14 May 2004 03:26:00 -0500 (CDT) |
Author: johannes
Date: 2004-05-14 03:25:59 -0500 (Fri, 14 May 2004)
New Revision: 5816
Modified:
trunk/gnue-common/src/schema/scripter/processors/Base.py
trunk/gnue-common/src/schema/scripter/processors/HTML.py
trunk/gnue-common/src/schema/scripter/processors/SQL.py
trunk/gnue-common/src/schema/scripter/processors/interbase.py
trunk/gnue-common/src/schema/scripter/processors/mssql.py
trunk/gnue-common/src/schema/scripter/processors/mysql.py
trunk/gnue-common/src/schema/scripter/processors/oracle.py
trunk/gnue-common/src/schema/scripter/processors/postgresql.py
Log:
Adding not-null-fields to existing tables works for PostgreSql too now
Modified: trunk/gnue-common/src/schema/scripter/processors/Base.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/Base.py 2004-05-14
07:45:00 UTC (rev 5815)
+++ trunk/gnue-common/src/schema/scripter/processors/Base.py 2004-05-14
08:25:59 UTC (rev 5816)
@@ -180,7 +180,7 @@
# Virtual: Process a single field of a table definition
# ---------------------------------------------------------------------------
- def _processField (self, tableDef, gsField, isLast):
+ def _processField (self, tableDef, gsField, isLast, forAlter = False):
"""
A processor can override this method to translate a single field. The
argument 'isLast' is set to True if gsField is the last field in the
Modified: trunk/gnue-common/src/schema/scripter/processors/HTML.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/HTML.py 2004-05-14
07:45:00 UTC (rev 5815)
+++ trunk/gnue-common/src/schema/scripter/processors/HTML.py 2004-05-14
08:25:59 UTC (rev 5816)
@@ -81,7 +81,7 @@
# Translate all fields into a single row
# ---------------------------------------------------------------------------
- def _processField (self, tableDef, gsField, isLast):
+ def _processField (self, tableDef, gsField, isLast, forAlter = False):
tableDef.getPhase (0).body.extend (self._fieldRow (gsField))
Modified: trunk/gnue-common/src/schema/scripter/processors/SQL.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/SQL.py 2004-05-14
07:45:00 UTC (rev 5815)
+++ trunk/gnue-common/src/schema/scripter/processors/SQL.py 2004-05-14
08:25:59 UTC (rev 5816)
@@ -87,7 +87,7 @@
for field in tableDef.fields:
phase.body.append (u"ALTER TABLE %s ADD " % tableDef.name)
- self._processField (tableDef, field, True)
+ self._processField (tableDef, field, True, True)
phase.body.append ("%s" % self.END_COMMAND)
@@ -96,7 +96,7 @@
# A single field is usually added to the definitions body
# ---------------------------------------------------------------------------
- def _processField (self, tableDef, gsField, isLast):
+ def _processField (self, tableDef, gsField, isLast, forAlter = False):
"""
Default implementation: Add the qualified field to the table definitions
body.
Modified: trunk/gnue-common/src/schema/scripter/processors/interbase.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/interbase.py
2004-05-14 07:45:00 UTC (rev 5815)
+++ trunk/gnue-common/src/schema/scripter/processors/interbase.py
2004-05-14 08:25:59 UTC (rev 5816)
@@ -41,7 +41,7 @@
# ---------------------------------------------------------------------------
# Add a GSField instance to the table definition
# ---------------------------------------------------------------------------
- def _processField (self, tableDef, gsField, isLast):
+ def _processField (self, tableDef, gsField, isLast, forAlter = False):
field = " %s" % self._qualify (gsField)
phase = tableDef.getPhase (0)
Modified: trunk/gnue-common/src/schema/scripter/processors/mssql.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/mssql.py 2004-05-14
07:45:00 UTC (rev 5815)
+++ trunk/gnue-common/src/schema/scripter/processors/mssql.py 2004-05-14
08:25:59 UTC (rev 5816)
@@ -39,7 +39,7 @@
# ---------------------------------------------------------------------------
# Process a GSField instance
# ---------------------------------------------------------------------------
- def _processField (self, tableDef, gsField, isLast):
+ def _processField (self, tableDef, gsField, isLast, forAlter = False):
field = " %s" % self._qualify (gsField)
# build a default value for this field
Modified: trunk/gnue-common/src/schema/scripter/processors/mysql.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/mysql.py 2004-05-14
07:45:00 UTC (rev 5815)
+++ trunk/gnue-common/src/schema/scripter/processors/mysql.py 2004-05-14
08:25:59 UTC (rev 5816)
@@ -40,7 +40,7 @@
# Process a GSField instance
# ---------------------------------------------------------------------------
- def _processField (self, tableDef, gsField, isLast):
+ def _processField (self, tableDef, gsField, isLast, forAlter = False):
field = " %s" % self._qualify (gsField)
if gsField.defaultwith == "serial":
Modified: trunk/gnue-common/src/schema/scripter/processors/oracle.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/oracle.py 2004-05-14
07:45:00 UTC (rev 5815)
+++ trunk/gnue-common/src/schema/scripter/processors/oracle.py 2004-05-14
08:25:59 UTC (rev 5816)
@@ -40,7 +40,7 @@
# ---------------------------------------------------------------------------
# add a GSField instance to the table definition
# ---------------------------------------------------------------------------
- def _processField (self, tableDef, gsField, isLast):
+ def _processField (self, tableDef, gsField, isLast, forAlter = False):
field = " %s" % self._qualify (gsField)
phase = tableDef.getPhase (0)
Modified: trunk/gnue-common/src/schema/scripter/processors/postgresql.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/postgresql.py
2004-05-14 07:45:00 UTC (rev 5815)
+++ trunk/gnue-common/src/schema/scripter/processors/postgresql.py
2004-05-14 08:25:59 UTC (rev 5816)
@@ -43,7 +43,7 @@
# Process a GSField instance
# ---------------------------------------------------------------------------
- def _processField (self, tableDef, gsField, isLast):
+ def _processField (self, tableDef, gsField, isLast, forAlter = False):
field = " %s" % self._qualify (gsField)
# build a default value for this field
@@ -59,7 +59,7 @@
elif hasattr (gsField, "default") and len (gsField.default):
field += " DEFAULT %s" % gsField.default
- if not gsField.nullable:
+ if not forAlter and not gsField.nullable:
field += " NOT NULL"
if not isLast:
@@ -68,6 +68,22 @@
tableDef.getPhase (0).body.append (field)
+ # ---------------------------------------------------------------------------
+ # Alter table field by field
+ # ---------------------------------------------------------------------------
+
+ def _alterSingle (self, tableDef):
+ SQLProcessor._alterSingle (self, tableDef)
+ phase = tableDef.getPhase (0)
+
+ for field in tableDef.fields:
+ if not field.nullable:
+ phase.body.append (u"ALTER TABLE %s" % tableDef.name)
+ phase.body.append (u" ALTER COLUMN %s SET NOT NULL%s" \
+ % (field.name, self.END_COMMAND))
+
+
+
# ===========================================================================
# Datatype translation
# ===========================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5816 - trunk/gnue-common/src/schema/scripter/processors,
johannes <=