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:
Marco Bubke
2023-05-01 10:23:53 +02:00
parent 5ab0b37ba1
commit 849b8cf000
2 changed files with 7 additions and 7 deletions

View File

@@ -63,7 +63,7 @@ public:
#pragma GCC diagnostic pop
#endif
constexpr bool isValid() const { return id >= 0; }
constexpr bool isValid() const { return id > 0; }
explicit operator bool() const { return isValid(); }
@@ -74,7 +74,7 @@ public:
[[noreturn, deprecated]] InternalIntegerType operator&() const { throw std::exception{}; }
private:
InternalIntegerType id = -1;
InternalIntegerType id = 0;
};
template<typename Container>

View File

@@ -90,11 +90,11 @@ protected:
Utils::PathString filePath5{"/file/pathFife"};
Utils::PathStringVector filePaths{filePath1, filePath2, filePath3, filePath4, filePath5};
Utils::PathStringVector reverseFilePaths{filePath1, filePath2, filePath3, filePath4, filePath5};
SourceContextId id1{SourceContextId::create(0)};
SourceContextId id2{SourceContextId::create(1)};
SourceContextId id3{SourceContextId::create(2)};
SourceContextId id4{SourceContextId::create(3)};
SourceContextId id5{SourceContextId::create(4)};
SourceContextId id1{SourceContextId::create(1)};
SourceContextId id2{SourceContextId::create(2)};
SourceContextId id3{SourceContextId::create(3)};
SourceContextId id4{SourceContextId::create(4)};
SourceContextId id5{SourceContextId::create(5)};
SourceContextId id41{SourceContextId::create(41)};
SourceContextId id42{SourceContextId::create(42)};
SourceContextId id43{SourceContextId::create(43)};