Skip to content

Commit

Permalink
processing postgis connector quote indexes names
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed May 22, 2019
1 parent a4187a7 commit fd4895b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions python/plugins/processing/tools/postgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def field_def(self):
ALTER TABLE command.
"""

data_type = (self.data_type if not self.modifier or self.modifier <
0 else '%s(%d)' % (self.data_type, self.modifier))
data_type = (self.data_type if not self.modifier or self.modifier
< 0 else '%s(%d)' % (self.data_type, self.modifier))
txt = '%s %s %s' % (self._quote(self.name), data_type,
self.is_null_txt())
if self.default and len(self.default) > 0:
Expand Down Expand Up @@ -721,20 +721,20 @@ def create_index(self, table, name, column, schema=None):

table_name = self._table_name(schema, table)
idx_name = self._quote(name)
sql = 'CREATE INDEX %s ON %s (%s)' % (idx_name, table_name,
self._quote(column))
sql = 'CREATE INDEX "%s" ON %s (%s)' % (idx_name, table_name,
self._quote(column))
self._exec_sql_and_commit(sql)

def create_spatial_index(self, table, schema=None, geom_column='the_geom'):
table_name = self._table_name(schema, table)
idx_name = self._quote(u"sidx_%s_%s" % (table, geom_column))
sql = 'CREATE INDEX %s ON %s USING GIST(%s)' % (idx_name, table_name,
self._quote(geom_column))
sql = 'CREATE INDEX "%s" ON %s USING GIST(%s)' % (idx_name, table_name,
self._quote(geom_column))
self._exec_sql_and_commit(sql)

def delete_index(self, name, schema=None):
index_name = self._table_name(schema, name)
sql = 'DROP INDEX %s' % index_name
sql = 'DROP INDEX "%s"' % index_name
self._exec_sql_and_commit(sql)

def get_database_privileges(self):
Expand Down Expand Up @@ -831,8 +831,8 @@ def _exec_sql(self, cursor, sql):
try:
cursor.execute(sql)
except psycopg2.Error as e:
raise QgsProcessingException(str(e) + ' QUERY: ' +
e.cursor.query.decode(e.cursor.connection.encoding))
raise QgsProcessingException(str(e) + ' QUERY: '
+ e.cursor.query.decode(e.cursor.connection.encoding))

def _exec_sql_and_commit(self, sql):
"""Tries to execute and commit some action, on error it rolls
Expand Down

0 comments on commit fd4895b

Please sign in to comment.