forked from qt-creator/qt-creator
QmlDesigner: Improve sqlite id
https://www.sqlite.org/autoinc.html says that "If no negative ROWID values are inserted explicitly, then automatically generated ROWID values will always be greater than zero." So zero is an invalid value. This changes reflect on it and makes it an invalid value too. Null is a special value in SQL and it could cast to zero by accident. To prevent that ambiguty we make zero an invalid value too. You can explicit add negative rowids but that has size overhead because positive values can be compressed. So explicit not positive values are not supported. Change-Id: I417ea9fec1573cfd9f1a98134f8adc567021988c Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -63,7 +63,7 @@ public:
|
|||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
constexpr bool isValid() const { return id >= 0; }
|
constexpr bool isValid() const { return id > 0; }
|
||||||
|
|
||||||
explicit operator bool() const { return isValid(); }
|
explicit operator bool() const { return isValid(); }
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
[[noreturn, deprecated]] InternalIntegerType operator&() const { throw std::exception{}; }
|
[[noreturn, deprecated]] InternalIntegerType operator&() const { throw std::exception{}; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InternalIntegerType id = -1;
|
InternalIntegerType id = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
|
@@ -90,11 +90,11 @@ protected:
|
|||||||
Utils::PathString filePath5{"/file/pathFife"};
|
Utils::PathString filePath5{"/file/pathFife"};
|
||||||
Utils::PathStringVector filePaths{filePath1, filePath2, filePath3, filePath4, filePath5};
|
Utils::PathStringVector filePaths{filePath1, filePath2, filePath3, filePath4, filePath5};
|
||||||
Utils::PathStringVector reverseFilePaths{filePath1, filePath2, filePath3, filePath4, filePath5};
|
Utils::PathStringVector reverseFilePaths{filePath1, filePath2, filePath3, filePath4, filePath5};
|
||||||
SourceContextId id1{SourceContextId::create(0)};
|
SourceContextId id1{SourceContextId::create(1)};
|
||||||
SourceContextId id2{SourceContextId::create(1)};
|
SourceContextId id2{SourceContextId::create(2)};
|
||||||
SourceContextId id3{SourceContextId::create(2)};
|
SourceContextId id3{SourceContextId::create(3)};
|
||||||
SourceContextId id4{SourceContextId::create(3)};
|
SourceContextId id4{SourceContextId::create(4)};
|
||||||
SourceContextId id5{SourceContextId::create(4)};
|
SourceContextId id5{SourceContextId::create(5)};
|
||||||
SourceContextId id41{SourceContextId::create(41)};
|
SourceContextId id41{SourceContextId::create(41)};
|
||||||
SourceContextId id42{SourceContextId::create(42)};
|
SourceContextId id42{SourceContextId::create(42)};
|
||||||
SourceContextId id43{SourceContextId::create(43)};
|
SourceContextId id43{SourceContextId::create(43)};
|
||||||
|
Reference in New Issue
Block a user