Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to run a sql query on a database through db manage broken, throws error #16905

Closed
qgib opened this issue Jun 14, 2013 · 4 comments
Closed
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! DB Manager Relating to the DB Manager core plugin
Milestone

Comments

@qgib
Copy link
Contributor

qgib commented Jun 14, 2013

Author Name: Mathieu Pellerin - nIRV (Mathieu Pellerin - nIRV)
Original Redmine Issue: 8066
Affected QGIS version: master
Redmine category:db_manager


Steps to reproduce:

  1. Open db manager
  2. Enter into a database (spatialite or postgis, doesn't matter)
  3. Open the SQL window
  4. Enter a simple SQL query (i.e. select * from my_table)
  5. Click on Execture
  6. QGIS throws a python error console with this content:
An error has occured while executing Python code:

Traceback (most recent call last):
  File "C:/OSGeo4W/apps/qgis-dev/./python/plugins\\db_manager\\dlg_sql_window.py", line 144, in executeSql
    sql = self.getSql()
  File "C:/OSGeo4W/apps/qgis-dev/./python/plugins\\db_manager\\dlg_sql_window.py", line 137, in getSql
    sql = sql.replace( QRegExp( ";\\\\s*$" ), "" )
TypeError: coercing to Unicode: need string or buffer, QRegExp found

Python version:
2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]


QGIS version:
1.9.0-Master Master, d547b25

Python path: ['C:/OSGeo4W/apps/qgis-dev/./python/plugins\\\\sextante', 'C:/OSGeo4W/apps/qgis-dev/./python', 'C:\\\\Users\\\\MATH/.qgis2/python', 'C:\\\\Users\\\\MATH/.qgis2/python/plugins', 'C:/OSGeo4W/apps/qgis-dev/./python/plugins', 'C:\\\\OSGeo4W\\\\apps\\\\orfeotoolbox\\\\wrapping\\\\lib', 'C:\\\\OSGeo4W\\\\apps\\\\orfeotoolbox\\\\wrapping\\\\Python', 'C:\\\\OSGeo4W\\\\apps\\\\orfeotoolbox\\\\python', 'C:\\\\', 'C:\\\\OSGeo4W\\\\bin\\\\python27.zip', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\DLLs', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\plat-win', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\lib-tk', 'C:\\\\OSGeo4W\\\\bin', 'C:\\\\OSGeo4W\\\\apps\\\\Python27', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\PIL', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32\\\\lib', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Pythonwin', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\wx-2.8-msw-unicode', 'C:\\\\OSGeo4W\\\\apps\\\\qgis-dev\\\\python\\\\plugins\\\\fTools\\\\tools']
<p>

Flagging this as a blocker as it breaks SQL execution.

@qgib
Copy link
Contributor Author

qgib commented Jun 14, 2013

Author Name: Gavin Fleming (@gubuntu)


affects me too, same description.

@qgib
Copy link
Contributor Author

qgib commented Jun 14, 2013

Author Name: Salvatore Larosa (@slarosa)


can not be reproduced here on the latest master (Linux).

I don't understand why it happens on Windows, maybe converting
the QRegExp to str might helps ??

If you can give at it a try apply the following patch (I cannot test on Windows just guessing here)

diff --git a/python/plugins/db_manager/dlg_sql_window.py b/python/plugins/db_manager/dlg_sql_window.
index 106be27..efa1d8b 100644
--- a/python/plugins/db_manager/dlg_sql_window.py
+++ b/python/plugins/db_manager/dlg_sql_window.py
@@ -134,7 +134,7 @@ class DlgSqlWindow(QDialog, Ui_Dialog):
     if sql == "":
       sql = self.editSql.toPlainText()
     # try to sanitize query
-    sql = sql.replace( QRegExp( ";\\\\s*$" ), "" )
+    sql = sql.replace( str(QRegExp( ";\\\\s*$" )), "" )
     return sql
 
   def clearSql(self):


@qgib
Copy link
Contributor Author

qgib commented Jun 15, 2013

Author Name: Giovanni Manghi (@gioman)


  • pull_request_patch_supplied was changed from 0 to 1

@qgib
Copy link
Contributor Author

qgib commented Jun 15, 2013

Author Name: Jürgen Fischer (@jef-n)


Fixed in changeset "192e13013b24d8c3be3584555db11b9ab61dec37".


  • status_id was changed from Open to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! DB Manager Relating to the DB Manager core plugin labels May 24, 2019
@qgib qgib added this to the Version 2.0.0 milestone May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! DB Manager Relating to the DB Manager core plugin
Projects
None yet
Development

No branches or pull requests

1 participant