extract blob to DB API, make sql scripts more psql friendly
This commit is contained in:
parent
fc8f0d3f52
commit
3ac28d135c
@ -1 +1 @@
|
||||
Subproject commit 47f4125753452eff8800dbd6600c5a05540b15d9
|
||||
Subproject commit 9c10723bfbaf6cb85107d6ee16e0324e9e487749
|
@ -23,7 +23,7 @@ CREATE TABLE Categories (
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created BIGINT,
|
||||
icon BLOB,
|
||||
icon °°,
|
||||
account_id INTEGER NOT NULL,
|
||||
custom_id TEXT,
|
||||
|
||||
@ -35,10 +35,10 @@ CREATE TABLE Feeds (
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created BIGINT,
|
||||
icon BLOB,
|
||||
icon °°,
|
||||
category INTEGER NOT NULL CHECK (category >= -1), /* Root feeds contain -1 here. */
|
||||
source TEXT,
|
||||
update_type INTEGER(1) NOT NULL CHECK (update_type >= 0),
|
||||
update_type INTEGER NOT NULL CHECK (update_type >= 0),
|
||||
update_interval INTEGER NOT NULL DEFAULT 15 CHECK (update_interval >= 1),
|
||||
account_id INTEGER NOT NULL,
|
||||
custom_id TEXT NOT NULL CHECK (custom_id != ''), /* Custom ID cannot be empty, it must contain either service-specific ID, or Feeds/id. */
|
||||
@ -50,10 +50,10 @@ CREATE TABLE Feeds (
|
||||
-- !
|
||||
CREATE TABLE Messages (
|
||||
id $$,
|
||||
is_read INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_read >= 0 AND is_read <= 1),
|
||||
is_important INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_important >= 0 AND is_important <= 1),
|
||||
is_deleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_deleted >= 0 AND is_deleted <= 1),
|
||||
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
||||
is_read INTEGER NOT NULL DEFAULT 0 CHECK (is_read >= 0 AND is_read <= 1),
|
||||
is_important INTEGER NOT NULL DEFAULT 0 CHECK (is_important >= 0 AND is_important <= 1),
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0 CHECK (is_deleted >= 0 AND is_deleted <= 1),
|
||||
is_pdeleted INTEGER NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
||||
feed TEXT NOT NULL, /* Points to Feeds/custom_id. */
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT,
|
||||
|
@ -48,5 +48,7 @@ QStringList DatabaseDriver::prepareScript(const QString& base_sql_folder,
|
||||
|
||||
statements.replaceInStrings(APP_DB_NAME_PLACEHOLDER, database_name);
|
||||
statements.replaceInStrings(APP_DB_AUTO_INC_PRIM_KEY_PLACEHOLDER, autoIncrementPrimaryKey());
|
||||
statements.replaceInStrings(APP_DB_BLOB_PLACEHOLDER, blob());
|
||||
|
||||
return statements;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class DatabaseDriver : public QObject {
|
||||
virtual QString qtDriverCode() const = 0;
|
||||
virtual DriverType driverType() const = 0;
|
||||
virtual QString autoIncrementPrimaryKey() const = 0;
|
||||
virtual QString blob() const = 0;
|
||||
virtual bool vacuumDatabase() = 0;
|
||||
virtual bool saveDatabase() = 0;
|
||||
virtual void backupDatabase(const QString& backup_folder, const QString& backup_name) = 0;
|
||||
|
@ -298,3 +298,7 @@ QSqlDatabase MariaDbDriver::connection(const QString& connection_name, DatabaseD
|
||||
QString MariaDbDriver::autoIncrementPrimaryKey() const {
|
||||
return QSL("INTEGER AUTO_INCREMENT PRIMARY KEY");
|
||||
}
|
||||
|
||||
QString MariaDbDriver::blob() const {
|
||||
return QSL("BLOB");
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ class MariaDbDriver : public DatabaseDriver {
|
||||
virtual QSqlDatabase connection(const QString& connection_name,
|
||||
DatabaseDriver::DesiredStorageType desired_type = DatabaseDriver::DesiredStorageType::FromSettings);
|
||||
virtual QString autoIncrementPrimaryKey() const;
|
||||
virtual QString blob() const;
|
||||
|
||||
QString interpretErrorCode(MariaDbError error_code) const;
|
||||
|
||||
|
@ -429,3 +429,7 @@ void SqliteDriver::backupDatabase(const QString& backup_folder, const QString& b
|
||||
QString SqliteDriver::autoIncrementPrimaryKey() const {
|
||||
return QSL("INTEGER PRIMARY KEY");
|
||||
}
|
||||
|
||||
QString SqliteDriver::blob() const {
|
||||
return QSL("BLOB");
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class SqliteDriver : public DatabaseDriver {
|
||||
virtual QString qtDriverCode() const;
|
||||
virtual void backupDatabase(const QString& backup_folder, const QString& backup_name);
|
||||
virtual QString autoIncrementPrimaryKey() const;
|
||||
virtual QString blob() const;
|
||||
|
||||
private:
|
||||
QSqlDatabase initializeDatabase(const QString& connection_name, bool in_memory);
|
||||
|
@ -158,6 +158,7 @@
|
||||
#define APP_DB_INCLUDE_PLACEHOLDER "!!"
|
||||
#define APP_DB_NAME_PLACEHOLDER "##"
|
||||
#define APP_DB_AUTO_INC_PRIM_KEY_PLACEHOLDER "$$"
|
||||
#define APP_DB_BLOB_PLACEHOLDER "°°"
|
||||
|
||||
#define APP_CFG_PATH "config"
|
||||
#define APP_CFG_FILE "config.ini"
|
||||
|
@ -221,7 +221,7 @@ void SettingsBrowserMail::addExternalTool() {
|
||||
item->setData(0, Qt::ItemDataRole::UserRole, QVariant::fromValue(tool));
|
||||
m_ui->m_listTools->addTopLevelItem(item);
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
catch (const ApplicationException&) {
|
||||
// NOTE: Tool adding cancelled.
|
||||
}
|
||||
}
|
||||
@ -269,7 +269,7 @@ void SettingsBrowserMail::editSelectedExternalTool() {
|
||||
m_ui->m_listTools->currentItem()->setText(1, ext_tool.parameters());
|
||||
m_ui->m_listTools->currentItem()->setData(0, Qt::ItemDataRole::UserRole, QVariant::fromValue(ext_tool));
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
catch (const ApplicationException&) {
|
||||
// NOTE: Tool adding cancelled.
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user