[GRASS-SVN] r64770 - grass/trunk/gui/wxpython/dbmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Feb 28 05:50:40 PST 2015


Author: martinl
Date: 2015-02-28 05:50:40 -0800 (Sat, 28 Feb 2015)
New Revision: 64770

Modified:
   grass/trunk/gui/wxpython/dbmgr/base.py
Log:
wxGUI/dbmgr: improve handling string where values (check for quotes)


Modified: grass/trunk/gui/wxpython/dbmgr/base.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/base.py	2015-02-28 12:19:27 UTC (rev 64769)
+++ grass/trunk/gui/wxpython/dbmgr/base.py	2015-02-28 13:50:40 UTC (rev 64770)
@@ -1833,7 +1833,18 @@
             # simple sql statement
             whereCol = self.FindWindowById(self.layerPage[self.selLayer]['whereColumn']).GetStringSelection()
             whereOpe = self.FindWindowById(self.layerPage[self.selLayer]['whereOperator']).GetStringSelection()
-            whereVal = self.FindWindowById(self.layerPage[self.selLayer]['where']).GetValue().strip()
+            whereWin = self.FindWindowById(self.layerPage[self.selLayer]['where'])
+            whereVal = whereWin.GetValue().strip()
+            table    = self.dbMgrData['mapDBInfo'].layers[self.selLayer]["table"]
+            if self.dbMgrData['mapDBInfo'].tables[table][whereCol]['ctype'] == str:
+                # string attribute, check for quotes
+                whereVal = whereVal.replace('"', "'")
+                if not whereVal.startswith("'"):
+                    whereVal = "'" + whereVal
+                if not whereVal.endswith("'"):
+                    whereVal += "'"
+                whereWin.SetValue(whereVal)
+            
             try:
                 if len(whereVal) > 0:
                     showSelected = True



More information about the grass-commit mailing list