VMM/*: Use target column names in all INSERT statements. v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Wed, 02 Feb 2011 19:03:54 +0000
branchv0.6.x
changeset 379 7518d927d443
parent 378 af56cee51e67
child 380 5aaf2dd6b146
VMM/*: Use target column names in all INSERT statements. In order to avoid trouble after the definition of a table was changed.
VirtualMailManager/alias.py
VirtualMailManager/aliasdomain.py
VirtualMailManager/domain.py
VirtualMailManager/relocated.py
VirtualMailManager/transport.py
--- a/VirtualMailManager/alias.py	Tue Feb 01 16:57:09 2011 +0000
+++ b/VirtualMailManager/alias.py	Wed Feb 02 19:03:54 2011 +0000
@@ -125,8 +125,9 @@
             return destinations
         self._check_expansion(len(destinations))
         dbc = self._dbh.cursor()
-        dbc.executemany("INSERT INTO alias VALUES (%d, '%s', %%s)" %
-                        (self._gid, self._addr.localpart),
+        dbc.executemany("INSERT INTO alias (gid, address, destination) "
+                        "VALUES (%d, '%s', %%s)" % (self._gid,
+                                                    self._addr.localpart),
                         ((str(destination),) for destination in destinations))
         self._dbh.commit()
         dbc.close()
--- a/VirtualMailManager/aliasdomain.py	Tue Feb 01 16:57:09 2011 +0000
+++ b/VirtualMailManager/aliasdomain.py	Wed Feb 02 19:03:54 2011 +0000
@@ -75,8 +75,8 @@
             raise ADErr(_(u"The target domain '%s' doesn't exist.") %
                         self._domain.name, NO_SUCH_DOMAIN)
         dbc = self._dbh.cursor()
-        dbc.execute('INSERT INTO domain_name VALUES (%s, %s, FALSE)',
-                    (self._name, self._domain.gid))
+        dbc.execute('INSERT INTO domain_name (domainname, gid, is_primary) '
+                    'VALUES (%s, %s, FALSE)', (self._name, self._domain.gid))
         self._dbh.commit()
         dbc.close()
         self._gid = self._domain.gid
--- a/VirtualMailManager/domain.py	Tue Feb 01 16:57:09 2011 +0000
+++ b/VirtualMailManager/domain.py	Wed Feb 02 19:03:54 2011 +0000
@@ -166,10 +166,11 @@
                          DOMAIN_EXISTS)
         assert self._directory is not None and self._transport is not None
         dbc = self._dbh.cursor()
-        dbc.execute("INSERT INTO domain_data VALUES (%s, %s, %s)", (self._gid,
-                    self._transport.tid, self._directory))
-        dbc.execute("INSERT INTO domain_name VALUES (%s, %s, %s)", (self._name,
-                    self._gid, True))
+        dbc.execute('INSERT INTO domain_data (gid, tid, domaindir) VALUES '
+                    '(%s, %s, %s)', (self._gid, self._transport.tid,
+                                     self._directory))
+        dbc.execute('INSERT INTO domain_name (domainname, gid, is_primary) '
+                    'VALUES (%s, %s, TRUE)', (self._name, self._gid))
         self._dbh.commit()
         dbc.close()
         self._new = False
--- a/VirtualMailManager/relocated.py	Tue Feb 01 16:57:09 2011 +0000
+++ b/VirtualMailManager/relocated.py	Wed Feb 02 19:03:54 2011 +0000
@@ -82,7 +82,8 @@
 
         dbc = self._dbh.cursor()
         if not update:
-            dbc.execute('INSERT INTO relocated VALUES (%s, %s, %s)',
+            dbc.execute('INSERT INTO relocated (gid, address, destination) '
+                        'VALUES (%s, %s, %s)',
                         (self._gid, self._addr.localpart, str(self._dest)))
         else:
             dbc.execute('UPDATE relocated SET destination = %s WHERE gid = %s '
--- a/VirtualMailManager/transport.py	Tue Feb 01 16:57:09 2011 +0000
+++ b/VirtualMailManager/transport.py	Wed Feb 02 19:03:54 2011 +0000
@@ -96,8 +96,8 @@
         dbc = self._dbh.cursor()
         dbc.execute("SELECT nextval('transport_id')")
         self._tid = dbc.fetchone()[0]
-        dbc.execute('INSERT INTO transport VALUES (%s, %s)', (self._tid,
-                    self._transport))
+        dbc.execute('INSERT INTO transport (tid, transport) VALUES (%s, %s)',
+                    (self._tid, self._transport))
         self._dbh.commit()
         dbc.close()