mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-31 17:44:52 +01:00
Some changes to DB schema.
This commit is contained in:
parent
fbfeb9f91b
commit
e4fe5a9f13
@ -74,10 +74,10 @@ CREATE TABLE IF NOT EXISTS Messages (
|
||||
is_read INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_read >= 0 AND is_read <= 1),
|
||||
is_deleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_deleted >= 0 AND is_deleted <= 1),
|
||||
is_important INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_important >= 0 AND is_important <= 1),
|
||||
feed TEXT,
|
||||
feed TEXT NOT NULL,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT NOT NULL,
|
||||
author TEXT NOT NULL,
|
||||
author TEXT,
|
||||
date_created BIGINT NOT NULL CHECK (date_created != 0),
|
||||
contents TEXT,
|
||||
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
||||
|
@ -69,10 +69,10 @@ CREATE TABLE IF NOT EXISTS Messages (
|
||||
is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT (0),
|
||||
is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT (0),
|
||||
is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT (0),
|
||||
feed TEXT,
|
||||
feed TEXT NOT NULL,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT NOT NULL,
|
||||
author TEXT NOT NULL,
|
||||
author TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
contents TEXT,
|
||||
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
||||
|
@ -38,7 +38,7 @@ ALTER TABLE Messages
|
||||
DROP FOREIGN KEY feed;
|
||||
-- !
|
||||
ALTER TABLE Messages
|
||||
MODIFY Feeds TEXT;
|
||||
MODIFY feed TEXT NOT NULL;
|
||||
-- !
|
||||
ALTER TABLE Feeds
|
||||
MODIFY date_created BIGINT;
|
||||
@ -55,4 +55,7 @@ MODIFY type INTEGER;
|
||||
ALTER TABLE Categories
|
||||
MODIFY date_created BIGINT;
|
||||
-- !
|
||||
ALTER TABLE Messages
|
||||
MODIFY author TEXT;
|
||||
-- !
|
||||
UPDATE Information SET inf_value = '4' WHERE inf_key = 'schema_version';
|
@ -43,10 +43,10 @@ CREATE TABLE Messages (
|
||||
is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT (0),
|
||||
is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT (0),
|
||||
is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT (0),
|
||||
feed TEXT,
|
||||
feed TEXT NOT NULL,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT NOT NULL,
|
||||
author TEXT NOT NULL,
|
||||
author TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
contents TEXT,
|
||||
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
||||
|
@ -69,12 +69,12 @@ ServiceRoot *StandardServiceEntryPoint::createNewRoot() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int id_to_assing = query.value(0).toInt() + 1;
|
||||
int id_to_assign = query.value(0).toInt() + 1;
|
||||
|
||||
if (query.exec(QString("INSERT INTO Accounts (id, type) VALUES (%1, '%2');").arg(QString::number(id_to_assing),
|
||||
if (query.exec(QString("INSERT INTO Accounts (id, type) VALUES (%1, '%2');").arg(QString::number(id_to_assign),
|
||||
SERVICE_CODE_STD_RSS))) {
|
||||
StandardServiceRoot *root = new StandardServiceRoot();
|
||||
root->setAccountId(id_to_assing);
|
||||
root->setAccountId(id_to_assign);
|
||||
return root;
|
||||
}
|
||||
else {
|
||||
|
@ -376,7 +376,7 @@ QList<Message> TtRssGetHeadlinesResponse::messages() const {
|
||||
QMap<QString,QVariant> mapped = item.toMap();
|
||||
Message message;
|
||||
|
||||
message.m_author = mapped["author"].toString();
|
||||
message.m_author = mapped["author"].toString();
|
||||
message.m_isRead = !mapped["unread"].toBool();
|
||||
message.m_isImportant = mapped["marked"].toBool();
|
||||
message.m_contents = mapped["content"].toString();
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
|
||||
TtRssFeed::TtRssFeed(RootItem *parent)
|
||||
@ -251,6 +252,9 @@ int TtRssFeed::updateMessages(const QList<Message> &messages) {
|
||||
if (query_insert.exec() && query_insert.numRowsAffected() == 1) {
|
||||
updated_messages++;
|
||||
}
|
||||
else {
|
||||
QString str = query_insert.lastError().text();
|
||||
}
|
||||
|
||||
query_insert.finish();
|
||||
|
||||
|
@ -82,6 +82,7 @@ QList<ServiceRoot*> TtRssServiceEntryPoint::initializeSubtree() {
|
||||
if (query.exec("SELECT id, username, password, url FROM TtRssAccounts;")) {
|
||||
while (query.next()) {
|
||||
TtRssServiceRoot *root = new TtRssServiceRoot();
|
||||
root->setId(query.value(0).toInt());
|
||||
root->setAccountId(query.value(0).toInt());
|
||||
root->network()->setUsername(query.value(1).toString());
|
||||
root->network()->setPassword(query.value(2).toString());
|
||||
|
@ -251,17 +251,18 @@ void TtRssServiceRoot::saveAccountDataToDatabase() {
|
||||
return;
|
||||
}
|
||||
|
||||
int id_to_assing = query.value(0).toInt() + 1;
|
||||
int id_to_assign = query.value(0).toInt() + 1;
|
||||
|
||||
bool saved = query.exec(QString("INSERT INTO Accounts (id, type) VALUES (%1, '%2');").arg(QString::number(id_to_assing),
|
||||
bool saved = query.exec(QString("INSERT INTO Accounts (id, type) VALUES (%1, '%2');").arg(QString::number(id_to_assign),
|
||||
SERVICE_CODE_TT_RSS)) &&
|
||||
query.exec(QString("INSERT INTO TtRssAccounts (id, username, password, url) VALUES (%1, '%2', '%3', '%4');").arg(QString::number(id_to_assing),
|
||||
query.exec(QString("INSERT INTO TtRssAccounts (id, username, password, url) VALUES (%1, '%2', '%3', '%4');").arg(QString::number(id_to_assign),
|
||||
network()->username(),
|
||||
network()->password(),
|
||||
network()->url()));
|
||||
|
||||
if (saved) {
|
||||
setAccountId(id_to_assing);
|
||||
setId(id_to_assign);
|
||||
setAccountId(id_to_assign);
|
||||
updateTitle();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user