1 |
|
# |
2 |
|
# This file is part of GNU Enterprise. |
3 |
|
# |
4 |
|
# GNU Enterprise is free software; you can redistribute it |
5 |
|
# and/or modify it under the terms of the GNU General Public |
6 |
|
# License as published by the Free Software Foundation; either |
7 |
|
# version 2, or(at your option) any later version. |
8 |
|
# |
9 |
|
# GNU Enterprise is distributed in the hope that it will be |
10 |
|
# useful, but WITHOUT ANY WARRANTY; without even the implied |
11 |
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
12 |
|
# PURPOSE. See the GNU General Public License for more details. |
13 |
|
# |
14 |
|
# You should have received a copy of the GNU General Public |
15 |
|
# License along with program; see the file COPYING. If not, |
16 |
|
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
|
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
|
# |
19 |
|
# Copyright 2000-2003 Free Software Foundation |
20 |
|
# |
21 |
|
# FILE: |
22 |
|
# _pgsql/DBdriver.py |
23 |
|
# |
24 |
|
# DESCRIPTION: |
25 |
|
# A core Postgresql dbdriver that the other (specific) |
26 |
|
# postgresql drivers can extend |
27 |
|
# |
28 |
|
# NOTES: |
29 |
|
# |
30 |
|
|
31 |
|
__all__ = ['RecordSet'] |
32 |
|
|
33 |
|
import string |
34 |
|
from gnue.common.datasources.drivers import DBSIG2 |
35 |
|
|
36 |
|
|
37 |
|
# |
38 |
|
# |
39 |
|
# |
40 |
|
class RecordSet(DBSIG2.RecordSet): |
41 |
|
def _buildUpdateStatement(self): |
42 |
|
updates = [] |
43 |
|
for field in self._modifiedFlags.keys(): |
44 |
|
updates.append ("%s=%s" % (field, |
45 |
|
self._parent._dataObject._toSqlString(self._fields[field]))) |
46 |
|
|
47 |
|
if self._parent._dataObject._primaryIdField: |
48 |
|
where = [self._parent._dataObject._primaryIdFormat % \ |
49 |
|
self._initialData[self._parent._dataObject._primaryIdField] ] |
50 |
|
else: |
51 |
|
where = [] |
52 |
|
for field in self._initialData.keys(): |
53 |
|
if self._initialData[field] == None: |
54 |
|
where.append ("%s IS NULL" % field) |
55 |
|
else: |
56 |
|
where.append ("%s=%s" % (field, self._parent._dataObject._toSqlString(self._initialData[field]))) |
57 |
|
return "UPDATE %s SET %s WHERE %s" % \ |
58 |
|
(self._parent._dataObject.table, string.join(updates,','), \ |
59 |
|
string.join(where,' AND ') ) |
60 |
|
|
61 |
|
|