Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace db.connector/self + is None
  • Loading branch information
Ailurupoda committed Feb 8, 2019
1 parent 68c541b commit 9741515
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_plugins/gpkg/connector.py
Expand Up @@ -620,11 +620,11 @@ def runVacuum(self):
""" run vacuum on the db """
self._execute_and_commit("VACUUM")

def commentTable(self, schema, tablename, db, comment=None):
def commentTable(self, schema, tablename, comment=None):
"""Comment the table"""
return ''

def getComment(self, tablename, field, db):
def getComment(self, tablename, field):
"""Returns the comment for a field"""
return ''

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_plugins/oracle/connector.py
Expand Up @@ -1307,11 +1307,11 @@ def renameSchema(self, schema, new_schema):
# Unsupported in Oracle
pass

def commentTable(self, schema, tablename, db, comment=None):
def commentTable(self, schema, tablename, comment=None):
"""Comment the table"""
return ''

def getComment(self, tablename, field, db):
def getComment(self, tablename, field):
"""Returns the comment for a field"""
return ''

Expand Down
20 changes: 10 additions & 10 deletions python/plugins/db_manager/db_plugins/postgis/connector.py
Expand Up @@ -742,25 +742,25 @@ def renameTable(self, table, new_table):

self._commit()

def commentTable(self, schema, tablename, db, comment=None):
if comment == None:
db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS NULL;'.format(schema, tablename))
def commentTable(self, schema, tablename, comment=None):
if comment is None:
self._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS NULL;'.format(schema, tablename))
else:
db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\';'.format(schema, tablename, comment))
self._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\';'.format(schema, tablename, comment))

def getComment(self, tablename, field, db):
def getComment(self, tablename, field):
"""Returns the comment for a field"""
# SQL Query checking if a comment exists for the field
sql_cpt = "Select count(*) from pg_description pd, pg_class pc, pg_attribute pa where relname = '%s' and attname = '%s' and pa.attrelid = pc.oid and pd.objoid = pc.oid and pd.objsubid = pa.attnum" % (tablename, field)
# SQL Query that return the comment of the field
sql = "Select pd.description from pg_description pd, pg_class pc, pg_attribute pa where relname = '%s' and attname = '%s' and pa.attrelid = pc.oid and pd.objoid = pc.oid and pd.objsubid = pa.attnum" % (tablename, field)
c = db.connector._execute(None, sql_cpt) # Execute Check query
res = db.connector._fetchone(c)[0] # Store result
c = self._execute(None, sql_cpt) # Execute Check query
res = self._fetchone(c)[0] # Store result
if res == 1:
# When a comment exists
c = db.connector._execute(None, sql) # Execute query
res = db.connector._fetchone(c)[0] # Store result
db.connector._close_cursor(c) # Close cursor
c = self._execute(None, sql) # Execute query
res = self._fetchone(c)[0] # Store result
self._close_cursor(c) # Close cursor
return res # Return comment
else:
return ''
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_plugins/spatialite/connector.py
Expand Up @@ -571,11 +571,11 @@ def runVacuum(self):
c.execute('VACUUM')
self.connection.isolation_level = '' # reset to default isolation

def commentTable(self, schema, tablename, db, comment=None):
def commentTable(self, schema, tablename, comment=None):
"""Comment the table"""
return ''

def getComment(self, tablename, field, db):
def getComment(self, tablename, field):
"""Returns the comment for a field"""
return ''

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_plugins/vlayers/connector.py
Expand Up @@ -342,11 +342,11 @@ def runVacuum(self):
print("**unimplemented** runVacuum")
return False

def commentTable(self, schema, tablename, db, comment=None):
def commentTable(self, schema, tablename, comment=None):
"""Comment the table"""
return ''

def getComment(self, tablename, field, db):
def getComment(self, tablename, field):
"""Returns the comment for a field"""
return ''

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/dlg_field_properties.py
Expand Up @@ -67,7 +67,7 @@ def setField(self, fld):
print(tab)
field = fld.name
print(field)
res = self.db.connector.getComment(tab, field, self.db)
res = self.db.connector.getComment(tab, field)
print(res)
self.editCom.setText(res) # Set comment value
#except:
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/db_manager/dlg_import_vector.py
Expand Up @@ -376,7 +376,8 @@ def accept(self):
supportCom = self.db.supportsComment()
if self.chkCom.isEnabled() and self.chkCom.isChecked() and supportCom == True:
# using connector executing COMMENT ON TABLE query (with editCome.text() value)
self.db.connector.commentTable(schema, table, self.db, self.editCom.text())
com = self.editCome.text()
self.db.connector.commentTable(schema, table, com)

self.db.connection().reconnect()
self.db.refresh()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/db_manager/dlg_table_properties.py
Expand Up @@ -341,7 +341,7 @@ def createComment(self):
schem = self.table.schema().name
tab = self.table.name
com = self.viewComment.text()
self.db.connector.commentTable(schem, tab, self.db, com)
self.db.connector.commentTable(schem, tab, com)
except DbError as e:
DlgDbError.showError(e, self)
return
Expand All @@ -354,7 +354,7 @@ def deleteComment(self):
try:
schem = self.table.schema().name
tab = self.table.name
self.db.connector.commentTable(schem, tab, self.db)
self.db.connector.commentTable(schem, tab)
except DbError as e:
DlgDbError.showError(e, self)
return
Expand Down

0 comments on commit 9741515

Please sign in to comment.