commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/common/src/dbdrivers/_dbsig DBdriver.py


From: Arturas Kriukovas
Subject: gnue/common/src/dbdrivers/_dbsig DBdriver.py
Date: Mon, 15 Jul 2002 09:36:27 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Arturas Kriukovas <address@hidden>      02/07/15 09:36:27

Modified files:
        common/src/dbdrivers/_dbsig: DBdriver.py 

Log message:
        Added potentially problematic date\time format conversion from
        '2002-12-31 23:59:59,99' format into '2002-12-31 23:59:59' format.
        Problem may arise if we have some data that is exactly in this
        date\time format, but not a date\time - because the function will leave
        only the first part of the string before ',' - that's potential data
        loss. But if leave the initial format ('...,99'), then database has
        update\insert problems with data types.
        Changed _dateTimeFormat variable value from '%c' (what was system
        localised default date\time format) into '%Y-%m-%d %H:%M:%S'. The first
        one created problems with database insert\update by creating 'localised'
        SQL queries ('...WHERE month="May"...' does work in English, but it
        does not work translated into Lithuanian '...WHERE month="Geguþë"...').
        TODO: with other databases\database adapters the same problems may
        arise, but i'm unable to check this now because of databases shortage :)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/dbdrivers/_dbsig/DBdriver.py.diff?tr1=1.49&tr2=1.50&r1=text&r2=text

Patches:
Index: gnue/common/src/dbdrivers/_dbsig/DBdriver.py
diff -c gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.49 
gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.50
*** gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.49   Thu May 30 11:14:34 2002
--- gnue/common/src/dbdrivers/_dbsig/DBdriver.py        Mon Jul 15 09:36:27 2002
***************
*** 109,116 ****
    def _buildUpdateStatement(self):
      updates = []
      for field in self._modifiedFlags.keys():
        updates.append ("%s=%s" % (field,
!          self._parent._dataObject._toSqlString(self._fields[field])))
  
      if self._parent._dataObject._primaryIdField:
        where = [self._parent._dataObject._primaryIdFormat % \
--- 109,128 ----
    def _buildUpdateStatement(self):
      updates = []
      for field in self._modifiedFlags.keys():
+       # To convert date from format '2002-12-31 23:59:59,99'
+       # into '2002-12-31 23:59:59' format.
+       # We have to determine whether given string is date\time
+       # maybe it's the most stupid way, but it should work.
+       # TODO: if in ANY other field data of this format and comma in
+       # place will exist, the remaining string from first ',' will be
+       # eaten.
+       # If you know better decision - please, modify this code.
+       tmpDate = self._fields[field]
+       if ((len(tmpDate)==22) and (tmpDate[-3]==',')):
+         tmpDate = tmpDate.split(',')
+         tmpDate = tmpDate[0]
        updates.append ("%s=%s" % (field,
!          self._parent._dataObject._toSqlString(tmpDate)))
  
      if self._parent._dataObject._primaryIdField:
        where = [self._parent._dataObject._primaryIdFormat % \
***************
*** 228,234 ****
  
      # The date/time format used in insert/select statements
      # (based on format used for time.strftime())
!     self._dateTimeFormat = "'%c'"
  
  
    def _toSqlString(self, value):
--- 240,246 ----
  
      # The date/time format used in insert/select statements
      # (based on format used for time.strftime())
!     self._dateTimeFormat = "'%Y-%m-%d %H:%M:%S'"
  
  
    def _toSqlString(self, value):



reply via email to

[Prev in Thread] Current Thread [Next in Thread]