commit-gnue
[Top][All Lists]
Advanced

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

gnue common/src/GDataSource.py common/src/dbdri...


From: Jason Cater
Subject: gnue common/src/GDataSource.py common/src/dbdri...
Date: Thu, 31 Oct 2002 18:12:26 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/10/31 18:12:26

Modified files:
        common/src     : GDataSource.py 
        common/src/dbdrivers/_dbsig: DBdriver.py 
        common/src/dbdrivers/_pgsql: DBdriver.py 
        designer/src   : Designer.py 
        reports/src    : GRDataMapper.py 
Added files:
        reports/samples/cross-tabulation: README cross.grd 

Log message:
        added cross-tabulation (pivot table) example to reports (pending a few 
bugfixes, it will work); misc cleanup

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GDataSource.py.diff?tr1=1.42&tr2=1.43&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/dbdrivers/_dbsig/DBdriver.py.diff?tr1=1.57&tr2=1.58&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/dbdrivers/_pgsql/DBdriver.py.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/Designer.py.diff?tr1=1.52&tr2=1.53&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/samples/cross-tabulation/README?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/samples/cross-tabulation/cross.grd?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRDataMapper.py.diff?tr1=1.18&tr2=1.19&r1=text&r2=text

Patches:
Index: gnue/common/src/GDataSource.py
diff -c gnue/common/src/GDataSource.py:1.42 gnue/common/src/GDataSource.py:1.43
*** gnue/common/src/GDataSource.py:1.42 Sun Oct 27 21:10:26 2002
--- gnue/common/src/GDataSource.py      Thu Oct 31 18:12:26 2002
***************
*** 96,101 ****
--- 96,106 ----
          self._fieldReferences[field] = 1
      except AttributeError:
        pass
+     try:
+       for field in string.split(self.order_by,','):
+         self._fieldReferences[field] = 1
+     except AttributeError:
+       pass
      return GObjects.GObj._buildObject(self)
  
  
***************
*** 381,386 ****
--- 386,394 ----
                 'Typecast': GTypecast.whole,
                 'Default':  5 },
              'prequery':    {
+                'Typecast': GTypecast.boolean,
+                'Default':  0 },
+             'distinct':    {
                 'Typecast': GTypecast.boolean,
                 'Default':  0 },
              'order_by':    {
Index: gnue/common/src/dbdrivers/_dbsig/DBdriver.py
diff -c gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.57 
gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.58
*** gnue/common/src/dbdrivers/_dbsig/DBdriver.py:1.57   Sun Oct 27 15:59:38 2002
--- gnue/common/src/dbdrivers/_dbsig/DBdriver.py        Thu Oct 31 18:12:26 2002
***************
*** 214,219 ****
--- 214,221 ----
      self._DatabaseError = None
      self._strictQueryCount = strictQueryCount
  
+     self.distinct = 0
+ 
      # If a DB driver supports a unique identifier for rows,
      # list it here.  _primaryIdField is the field name (lower case)
      # that would appear in the recordset (note that this can be
***************
*** 326,332 ****
      else:
        cond = condition
  
!     if not len(cond._children):
        return ""
      elif len(cond._children) > 1:
        chillun = cond._children[:]
--- 328,334 ----
      else:
        cond = condition
  
!     if not len(cond._children): 
        return ""
      elif len(cond._children) > 1:
        chillun = cond._children[:]
***************
*** 416,422 ****
  
      return sql
  
!   def _buildTableDefinition(self,tbl):  
        
      sql="CREATE TABLE %s (" % tbl.name
  
--- 418,424 ----
  
      return sql
  
!   def _buildTableDefinition(self,tbl):
        
      sql="CREATE TABLE %s (" % tbl.name
  
***************
*** 426,432 ****
      fields=tbl.findChildOfType("GSFields")
  
      delim=""
!     
      for field in fields._children:
        
         sql=sql+delim+"%s" % self._buildFieldDefinition(field)
--- 428,434 ----
      fields=tbl.findChildOfType("GSFields")
  
      delim=""
! 
      for field in fields._children:
        
         sql=sql+delim+"%s" % self._buildFieldDefinition(field)
***************
*** 480,494 ****
          cursor.execute(sql)
          cursor.close()
  
!     
    # write Schema to Database
    def writeSchema(self,obj,overwrite=0):
      if obj._type=="GSTable":
        return self.writeTable(obj,overwrite)
!       
      elif obj._type=="GSView":
        return self.writeView(obj,overwrite)
!       
      else:
        # do the same for all children
        result=[]
--- 482,496 ----
          cursor.execute(sql)
          cursor.close()
  
! 
    # write Schema to Database
    def writeSchema(self,obj,overwrite=0):
      if obj._type=="GSTable":
        return self.writeTable(obj,overwrite)
! 
      elif obj._type=="GSView":
        return self.writeView(obj,overwrite)
! 
      else:
        # do the same for all children
        result=[]
***************
*** 514,530 ****
  
    def _buildQuery(self, conditions={}):
      GDebug.printMesg(7,'Implicit Fields: %s' % self._fieldReferences)
      if self._primaryIdSelect:
        pis = "%s," % self._primaryIdSelect
      else:
        pis = ""
      if len(self._fieldReferences):
!       q = "SELECT %s%s FROM %s%s" % \
!            (pis, string.join(self._fieldReferences.keys(),","), self.table,
              self._conditionToSQL(conditions))
      else:
        self._primaryIdSelect = None
!       q = "SELECT * FROM %s%s" % (self.table,
                          self._conditionToSQL(conditions))
  
      if hasattr(self,'order_by'):
--- 516,537 ----
  
    def _buildQuery(self, conditions={}):
      GDebug.printMesg(7,'Implicit Fields: %s' % self._fieldReferences)
+     if self.distinct:
+       distinct = "distinct "
+     else:
+       distinct = ""
+ 
      if self._primaryIdSelect:
        pis = "%s," % self._primaryIdSelect
      else:
        pis = ""
      if len(self._fieldReferences):
!       q = "SELECT %s%s%s FROM %s%s" % \
!            (distinct, pis, string.join(self._fieldReferences.keys(),","), 
self.table,
              self._conditionToSQL(conditions))
      else:
        self._primaryIdSelect = None
!       q = "SELECT %s* FROM %s%s" % (self.distinct, self.table,
                          self._conditionToSQL(conditions))
  
      if hasattr(self,'order_by'):
***************
*** 535,540 ****
--- 542,552 ----
      return q
  
    def _buildQueryCount(self, conditions={}):
+     if self.distinct:
+       distinct = "distinct "
+     else:
+       distinct = ""
+ 
      q = "SELECT count(*) FROM %s%s" % (self.table, 
self._conditionToSQL(conditions))
  
      GDebug.printMesg(5,q)
Index: gnue/common/src/dbdrivers/_pgsql/DBdriver.py
diff -c gnue/common/src/dbdrivers/_pgsql/DBdriver.py:1.23 
gnue/common/src/dbdrivers/_pgsql/DBdriver.py:1.24
*** gnue/common/src/dbdrivers/_pgsql/DBdriver.py:1.23   Thu Oct  3 10:35:48 2002
--- gnue/common/src/dbdrivers/_pgsql/DBdriver.py        Thu Oct 31 18:12:26 2002
***************
*** 250,256 ****
    def __getFieldSchema(self, parent):
  
      statement = "select attname, pg_type.oid, typname, " + \
!             " attnotnull, atthasdef, atttypmod, attnum " + \
              "from pg_attribute, pg_type " + \
              "where attrelid = %d and " % (parent.id) + \
              "pg_type.oid = atttypid and attnum >= 0" + \
--- 250,256 ----
    def __getFieldSchema(self, parent):
  
      statement = "select attname, pg_type.oid, typname, " + \
!             " attnotnull, atthasdef, atttypmod, attnum, attlen " + \
              "from pg_attribute, pg_type " + \
              "where attrelid = %d and " % (parent.id) + \
              "pg_type.oid = atttypid and attnum >= 0" + \
***************
*** 273,280 ****
        else:
          attrs['datatype']='text'
  
!       if rs[5] != -1:
!         attrs['length'] = rs[5]
  
        # Find any default values
        if rs[4]:
--- 273,283 ----
        else:
          attrs['datatype']='text'
  
!       if rs[7] > 0:
!         attrs['length'] = rs[7]
!       else:
!         attrs['length'] = rs[5] - 4
! 
  
        # Find any default values
        if rs[4]:
Index: gnue/designer/src/Designer.py
diff -c gnue/designer/src/Designer.py:1.52 gnue/designer/src/Designer.py:1.53
*** gnue/designer/src/Designer.py:1.52  Mon Oct 28 19:11:49 2002
--- gnue/designer/src/Designer.py       Thu Oct 31 18:12:26 2002
***************
*** 104,110 ****
      elif self.OPTIONS['new']:
        try:
          self.SetTopWindow(self.newInstance(self.OPTIONS['new']))
!       except ImportError: 
          self.handleStartupError('"%s" is not a valid option for --new' % 
self.OPTIONS['new'])
  
      else:
--- 104,110 ----
      elif self.OPTIONS['new']:
        try:
          self.SetTopWindow(self.newInstance(self.OPTIONS['new']))
!       except ImportError:
          self.handleStartupError('"%s" is not a valid option for --new' % 
self.OPTIONS['new'])
  
      else:
Index: gnue/reports/src/GRDataMapper.py
diff -c gnue/reports/src/GRDataMapper.py:1.18 
gnue/reports/src/GRDataMapper.py:1.19
*** gnue/reports/src/GRDataMapper.py:1.18       Sun Oct 20 22:16:02 2002
--- gnue/reports/src/GRDataMapper.py    Thu Oct 31 18:12:26 2002
***************
*** 189,195 ****
    #  the master-detail must be linked, the GRDataMapper will not have been
    #  created yet.  [Yes, it's fugly]
    def _masterChanged(self, masterResultSet, detailResultSet):
!     GDebug.printMesg (5, 'GRDataMapper._masterChanged')
      self._resultsets.insert(0,detailResultSet)
  
  
--- 189,195 ----
    #  the master-detail must be linked, the GRDataMapper will not have been
    #  created yet.  [Yes, it's fugly]
    def _masterChanged(self, masterResultSet, detailResultSet):
!     GDebug.printMesg (5, 'GRDataMapper._masterChanged on %s' % self.name)
      self._resultsets.insert(0,detailResultSet)
  
  




reply via email to

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