Skip to content

Commit 2a57b17

Browse files
committed
DBManager: avoid loading a query as layer with missing fields (fix #11037),
restore combo style and label when multiple unique fields for view are not supported (follow 8e45da9)
1 parent ef8f3d3 commit 2a57b17

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

python/plugins/db_manager/dlg_sql_window.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def __init__(self, iface, db, parent=None):
6161

6262
self.defaultLayerName = 'QueryLayer'
6363

64+
if self.allowMultiColumnPk:
65+
self.uniqueColumnCheck.setText(self.trUtf8("Column(s) with unique values"))
66+
else:
67+
self.uniqueColumnCheck.setText(self.trUtf8("Column with unique values"))
68+
6469
self.editSql.setFocus()
6570
self.editSql.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
6671
self.initCompleter()
@@ -82,15 +87,17 @@ def __init__(self, iface, db, parent=None):
8287

8388
self.updatePresetsCombobox()
8489

85-
self.uniqueCombo.setItemDelegate(QStyledItemDelegate())
90+
self.geomCombo.setEditable(True)
91+
self.geomCombo.lineEdit().setReadOnly(True)
92+
93+
self.uniqueCombo.setEditable(True)
94+
self.uniqueCombo.lineEdit().setReadOnly(True)
8695
self.uniqueModel = QStandardItemModel(self.uniqueCombo)
8796
self.uniqueCombo.setModel(self.uniqueModel)
8897
if self.allowMultiColumnPk:
89-
self.uniqueCombo.setEditable(True)
90-
self.uniqueCombo.lineEdit().setReadOnly(True)
98+
self.uniqueCombo.setItemDelegate(QStyledItemDelegate())
9199
self.uniqueModel.itemChanged.connect(self.uniqueChanged) # react to the (un)checking of an item
92100
self.uniqueCombo.lineEdit().textChanged.connect(self.uniqueTextChanged) # there are other events that change the displayed text and some of them can not be caught directly
93-
self.uniqueChanged
94101

95102
# hide the load query as layer if feature is not supported
96103
self._loadAsLayerAvailable = self.db.connector.hasCustomQuerySupport()
@@ -154,6 +161,8 @@ def loadPreset(self, name):
154161
def loadAsLayerToggled(self, checked):
155162
self.loadAsLayerGroup.setChecked(checked)
156163
self.loadAsLayerWidget.setVisible(checked)
164+
if checked:
165+
self.fillColumnCombos()
157166

158167
def clearSql(self):
159168
self.editSql.clear()

0 commit comments

Comments
 (0)