Skip to content

Commit

Permalink
Allow "getting" and setting case_sensitive_like pragma (#1494)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mgrojo authored and MKleusberg committed Aug 9, 2018
1 parent 282e673 commit 4f1256c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/MainWindow.cpp
Expand Up @@ -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();
}
Expand All @@ -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()
Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions src/MainWindow.h
Expand Up @@ -114,6 +114,7 @@ class MainWindow : public QMainWindow
int temp_store;
int user_version;
int wal_autocheckpoint;
int case_sensitive_like;
} pragmaValues;

enum StatementType
Expand Down
23 changes: 23 additions & 0 deletions src/MainWindow.ui
Expand Up @@ -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>
Expand Down
7 changes: 6 additions & 1 deletion src/sqlitedb.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 4f1256c

Please sign in to comment.