mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Replace db.connector/self + is None
This commit is contained in:
parent
68c541b969
commit
9741515fae
@ -620,11 +620,11 @@ class GPKGDBConnector(DBConnector):
|
||||
""" 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 ''
|
||||
|
||||
|
@ -1307,11 +1307,11 @@ class OracleDBConnector(DBConnector):
|
||||
# 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 ''
|
||||
|
||||
|
@ -742,25 +742,25 @@ class PostGisDBConnector(DBConnector):
|
||||
|
||||
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 ''
|
||||
|
@ -571,11 +571,11 @@ class SpatiaLiteDBConnector(DBConnector):
|
||||
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 ''
|
||||
|
||||
|
@ -342,11 +342,11 @@ class VLayerConnector(DBConnector):
|
||||
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 ''
|
||||
|
||||
|
@ -67,7 +67,7 @@ class DlgFieldProperties(QDialog, Ui_Dialog):
|
||||
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:
|
||||
|
@ -376,7 +376,8 @@ class DlgImportVector(QDialog, Ui_Dialog):
|
||||
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()
|
||||
|
@ -341,7 +341,7 @@ class DlgTableProperties(QDialog, Ui_Dialog):
|
||||
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
|
||||
@ -354,7 +354,7 @@ class DlgTableProperties(QDialog, Ui_Dialog):
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user