Allow "getting" and setting case_sensitive_like pragma (#1494)

* Allow "getting" and setting case_sensitive_like pragma

In order to allow case insensitive filtering, the pragma
case_sensitive_like is added to the GUI. Given that this pragma cannot be
read, a special SELECT request is made in DBBrowserDB::getPragma for
inferring its value.

See issue #1489.

* Warning in the pragma case_sensitive_like

This pragma has some peculiarities, so it is convenient to warn the user
about it through a tool-tip in the value.
This commit is contained in:
Manuel
2018-08-09 14:00:21 +02:00
committed by Martin Kleusberg
parent 282e6739d9
commit 4f1256cc5f
4 changed files with 33 additions and 1 deletions

View File

@@ -1881,6 +1881,7 @@ void MainWindow::loadPragmas()
pragmaValues.temp_store = db.getPragma("temp_store").toInt();
pragmaValues.user_version = db.getPragma("user_version").toInt();
pragmaValues.wal_autocheckpoint = db.getPragma("wal_autocheckpoint").toInt();
pragmaValues.case_sensitive_like = db.getPragma("case_sensitive_like").toInt();
updatePragmaUi();
}
@@ -1904,6 +1905,7 @@ void MainWindow::updatePragmaUi()
ui->comboboxPragmaTempStore->setCurrentIndex(pragmaValues.temp_store);
ui->spinPragmaUserVersion->setValue(pragmaValues.user_version);
ui->spinPragmaWalAutoCheckpoint->setValue(pragmaValues.wal_autocheckpoint);
ui->checkboxPragmaCaseSensitiveLike->setChecked(pragmaValues.case_sensitive_like);
}
void MainWindow::savePragmas()
@@ -1933,6 +1935,7 @@ void MainWindow::savePragmas()
db.setPragma("temp_store", ui->comboboxPragmaTempStore->currentIndex(), pragmaValues.temp_store);
db.setPragma("user_version", ui->spinPragmaUserVersion->value(), pragmaValues.user_version);
db.setPragma("wal_autocheckpoint", ui->spinPragmaWalAutoCheckpoint->value(), pragmaValues.wal_autocheckpoint);
db.setPragma("case_sensitive_like", ui->checkboxPragmaCaseSensitiveLike->isChecked(), pragmaValues.case_sensitive_like);
updatePragmaUi();
}

View File

@@ -114,6 +114,7 @@ private:
int temp_store;
int user_version;
int wal_autocheckpoint;
int case_sensitive_like;
} pragmaValues;
enum StatementType

View File

@@ -823,6 +823,29 @@ You can drag SQL statements from an object row and drop them into other applicat
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="labelPragmaCaseSensitiveLike">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://www.sqlite.org/pragma.html#pragma_case_sensitive_like&quot;&gt;Case Sensitive Like&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>checkboxPragmaCaseSensitiveLike</cstring>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QCheckBox" name="checkboxPragmaCaseSensitiveLike">
<property name="toolTip">
<string>Warning: this pragma is not readable and this value has been inferred. Writing the pragma might overwrite a redefined LIKE provided by an SQLite extension.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@@ -1646,7 +1646,12 @@ QString DBBrowserDB::getPragma(const QString& pragma)
if(!isOpen())
return QString();
QString sql = QString("PRAGMA %1").arg(pragma);
QString sql;
if (pragma=="case_sensitive_like")
sql = "SELECT 'x' NOT LIKE 'X'";
else
sql = QString("PRAGMA %1").arg(pragma);
sqlite3_stmt* vm;
const char* tail;
QString retval;