forked from qt-creator/qt-creator
QmlDesigner: Improving SessionChangeSets
Task-number: QDS-2998 Change-Id: I9b559bf593dd968172649d1f6c45fb9fb454f1a5 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -151,6 +151,11 @@ void Database::applyAndUpdateSessions()
|
|||||||
m_statements->sessions.applyAndUpdateSessions();
|
m_statements->sessions.applyAndUpdateSessions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SessionChangeSets Database::changeSets() const
|
||||||
|
{
|
||||||
|
return m_statements->sessions.changeSets();
|
||||||
|
}
|
||||||
|
|
||||||
const Utils::PathString &Database::databaseFilePath() const
|
const Utils::PathString &Database::databaseFilePath() const
|
||||||
{
|
{
|
||||||
return m_databaseFilePath;
|
return m_databaseFilePath;
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "sqlitedatabasebackend.h"
|
#include "sqlitedatabasebackend.h"
|
||||||
#include "sqlitedatabaseinterface.h"
|
#include "sqlitedatabaseinterface.h"
|
||||||
#include "sqliteglobal.h"
|
#include "sqliteglobal.h"
|
||||||
|
#include "sqlitesessionchangeset.h"
|
||||||
#include "sqlitetable.h"
|
#include "sqlitetable.h"
|
||||||
#include "sqlitetransaction.h"
|
#include "sqlitetransaction.h"
|
||||||
|
|
||||||
@@ -131,6 +132,8 @@ public:
|
|||||||
void setAttachedTables(const Utils::SmallStringVector &tables) override;
|
void setAttachedTables(const Utils::SmallStringVector &tables) override;
|
||||||
void applyAndUpdateSessions() override;
|
void applyAndUpdateSessions() override;
|
||||||
|
|
||||||
|
SessionChangeSets changeSets() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void deferredBegin() override;
|
void deferredBegin() override;
|
||||||
void immediateBegin() override;
|
void immediateBegin() override;
|
||||||
|
@@ -41,9 +41,10 @@ namespace Sqlite {
|
|||||||
|
|
||||||
class Sessions;
|
class Sessions;
|
||||||
|
|
||||||
namespace SessionChangeSetInternal {
|
|
||||||
enum class Operation : char { Invalid, Insert, Update, Delete };
|
enum class Operation : char { Invalid, Insert, Update, Delete };
|
||||||
|
|
||||||
|
namespace SessionChangeSetInternal {
|
||||||
|
|
||||||
class SentinelIterator
|
class SentinelIterator
|
||||||
{};
|
{};
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ public:
|
|||||||
ValueView oldValue;
|
ValueView oldValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConstTupleIterator
|
class SQLITE_EXPORT ConstTupleIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using difference_type = int;
|
using difference_type = int;
|
||||||
@@ -63,7 +64,9 @@ public:
|
|||||||
using reference = const ValueView &;
|
using reference = const ValueView &;
|
||||||
using iterator_category = std::forward_iterator_tag;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
|
||||||
ConstTupleIterator(sqlite3_changeset_iter *sessionIterator, int index, Operation operation)
|
ConstTupleIterator(sqlite3_changeset_iter *sessionIterator,
|
||||||
|
int index,
|
||||||
|
Sqlite::Operation operation)
|
||||||
: m_sessionIterator{sessionIterator}
|
: m_sessionIterator{sessionIterator}
|
||||||
, m_column{index}
|
, m_column{index}
|
||||||
, m_operation{operation}
|
, m_operation{operation}
|
||||||
@@ -91,10 +94,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
sqlite3_changeset_iter *m_sessionIterator = {};
|
sqlite3_changeset_iter *m_sessionIterator = {};
|
||||||
int m_column = 0;
|
int m_column = 0;
|
||||||
Operation m_operation = Operation::Invalid;
|
Sqlite::Operation m_operation = Sqlite::Operation::Invalid;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Tuple
|
class SQLITE_EXPORT Tuple
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using difference_type = int;
|
using difference_type = int;
|
||||||
@@ -108,7 +111,7 @@ public:
|
|||||||
Utils::SmallStringView table;
|
Utils::SmallStringView table;
|
||||||
sqlite3_changeset_iter *sessionIterator = {};
|
sqlite3_changeset_iter *sessionIterator = {};
|
||||||
int columnCount = 0;
|
int columnCount = 0;
|
||||||
Operation operation = Operation::Invalid;
|
Sqlite::Operation operation = Sqlite::Operation::Invalid;
|
||||||
|
|
||||||
ValueViews operator[](int column) const;
|
ValueViews operator[](int column) const;
|
||||||
ConstTupleIterator begin() const { return {sessionIterator, 0, operation}; }
|
ConstTupleIterator begin() const { return {sessionIterator, 0, operation}; }
|
||||||
@@ -117,7 +120,7 @@ public:
|
|||||||
|
|
||||||
enum class State : char { Invalid, Row, Done };
|
enum class State : char { Invalid, Row, Done };
|
||||||
|
|
||||||
class ConstIterator
|
class SQLITE_EXPORT ConstIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using difference_type = long;
|
using difference_type = long;
|
||||||
|
@@ -415,6 +415,22 @@ std::ostream &operator<<(std::ostream &out, sqlite3_changeset_iter *iter)
|
|||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *toText(Operation operation)
|
||||||
|
{
|
||||||
|
switch (operation) {
|
||||||
|
case Operation::Invalid:
|
||||||
|
return "Invalid";
|
||||||
|
case Operation::Insert:
|
||||||
|
return "Invalid";
|
||||||
|
case Operation::Update:
|
||||||
|
return "Invalid";
|
||||||
|
case Operation::Delete:
|
||||||
|
return "Invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const SessionChangeSet &changeset)
|
std::ostream &operator<<(std::ostream &out, const SessionChangeSet &changeset)
|
||||||
@@ -437,25 +453,14 @@ std::ostream &operator<<(std::ostream &out, const SessionChangeSet &changeset)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &out, Operation operation)
|
||||||
|
{
|
||||||
|
return out << toText(operation);
|
||||||
|
}
|
||||||
|
|
||||||
namespace SessionChangeSetInternal {
|
namespace SessionChangeSetInternal {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char *toText(Operation operation)
|
|
||||||
{
|
|
||||||
switch (operation) {
|
|
||||||
case Operation::Invalid:
|
|
||||||
return "Invalid";
|
|
||||||
case Operation::Insert:
|
|
||||||
return "Invalid";
|
|
||||||
case Operation::Update:
|
|
||||||
return "Invalid";
|
|
||||||
case Operation::Delete:
|
|
||||||
return "Invalid";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *toText(State state)
|
const char *toText(State state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
@@ -476,11 +481,6 @@ std::ostream &operator<<(std::ostream &out, SentinelIterator)
|
|||||||
return out << "sentinel";
|
return out << "sentinel";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, Operation operation)
|
|
||||||
{
|
|
||||||
return out << toText(operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, State state)
|
std::ostream &operator<<(std::ostream &out, State state)
|
||||||
{
|
{
|
||||||
return out << toText(state);
|
return out << toText(state);
|
||||||
|
@@ -68,24 +68,25 @@ namespace Sqlite {
|
|||||||
class Value;
|
class Value;
|
||||||
class ValueView;
|
class ValueView;
|
||||||
class SessionChangeSet;
|
class SessionChangeSet;
|
||||||
|
enum class Operation : char;
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const Value &value);
|
std::ostream &operator<<(std::ostream &out, const Value &value);
|
||||||
std::ostream &operator<<(std::ostream &out, const ValueView &value);
|
std::ostream &operator<<(std::ostream &out, const ValueView &value);
|
||||||
|
std::ostream &operator<<(std::ostream &out, Operation operation);
|
||||||
std::ostream &operator<<(std::ostream &out, const SessionChangeSet &changeset);
|
std::ostream &operator<<(std::ostream &out, const SessionChangeSet &changeset);
|
||||||
|
|
||||||
namespace SessionChangeSetInternal {
|
namespace SessionChangeSetInternal {
|
||||||
class ConstIterator;
|
class ConstIterator;
|
||||||
class ConstTupleIterator;
|
class ConstTupleIterator;
|
||||||
class SentinelIterator;
|
class SentinelIterator;
|
||||||
class Tuple;
|
class Tuple;
|
||||||
class ValueViews;
|
class ValueViews;
|
||||||
enum class Operation : char;
|
|
||||||
enum class State : char;
|
enum class State : char;
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, SentinelIterator iterator);
|
std::ostream &operator<<(std::ostream &out, SentinelIterator iterator);
|
||||||
std::ostream &operator<<(std::ostream &out, const ConstIterator &iterator);
|
std::ostream &operator<<(std::ostream &out, const ConstIterator &iterator);
|
||||||
std::ostream &operator<<(std::ostream &out, const ConstTupleIterator &iterator);
|
std::ostream &operator<<(std::ostream &out, const ConstTupleIterator &iterator);
|
||||||
std::ostream &operator<<(std::ostream &out, const Tuple &tuple);
|
std::ostream &operator<<(std::ostream &out, const Tuple &tuple);
|
||||||
std::ostream &operator<<(std::ostream &out, Operation operation);
|
|
||||||
std::ostream &operator<<(std::ostream &out, State operation);
|
std::ostream &operator<<(std::ostream &out, State operation);
|
||||||
std::ostream &operator<<(std::ostream &out, const ValueViews &valueViews);
|
std::ostream &operator<<(std::ostream &out, const ValueViews &valueViews);
|
||||||
|
|
||||||
|
@@ -36,9 +36,9 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using Sqlite::Operation;
|
||||||
using Sqlite::SessionChangeSet;
|
using Sqlite::SessionChangeSet;
|
||||||
using Sqlite::SessionChangeSets;
|
using Sqlite::SessionChangeSets;
|
||||||
using Sqlite::SessionChangeSetInternal::Operation;
|
|
||||||
using Sqlite::SessionChangeSetInternal::ValueViews;
|
using Sqlite::SessionChangeSetInternal::ValueViews;
|
||||||
|
|
||||||
class DatabaseExecute
|
class DatabaseExecute
|
||||||
|
Reference in New Issue
Block a user