浏览代码

wxGUI/dbmgr: improve handling string where values (check for quotes)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@64770 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 年之前
父节点
当前提交
775f59a9cd
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12 1
      gui/wxpython/dbmgr/base.py

+ 12 - 1
gui/wxpython/dbmgr/base.py

@@ -1833,7 +1833,18 @@ class DbMgrBrowsePage(DbMgrNotebookBase):
             # 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