Sometimes it is handy to return a range so you can break in a for range
loop. So you can now write:
for (auto [key, value] :
statement.range<std::tuple<long long, std::string>>()) {
values.push_back(value);
if (value == Tuple{"foo", 23.3, 2})
break;
}
for (auto [key, value] :
statement.rangeWithTransaction<std::tuple<long long, std::string>>()) {
values.push_back(value);
if (value == Tuple{"foo", 23.3, 2})
break;
}
It will only step over the statement to the break. So you don't fetch
not used values anymore. The second version will add a transaction
around the range.
But be careful. The range is view to the statement. Holding it longer or
reusing it can lead to strange behavior because the state of the
statement is changing.
Change-Id: I90191f7da5a015c7d8077d5bc428655a2b53246c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Missed to remove the not anymore used ResultTypeCount.
Change-Id: Ia150e945bd650cc1e3d19fcb9426621d93fa16c3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
It move the magic number of column results to the sql statement
and improves the mock a little bit.
Change-Id: I101067444cf27ec5dea0c72de7fd484a7e8710f0
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
There are cases when you want to read to an already existing container.
This will prepare for the RETURNING extension in the next Sqlite version
where you can write and read. That will simplify quite some code.
Change-Id: I740ffbedecf72bb5518392f3707a0a6b2221db56
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Sometimes it is better to have a callback instead of returning a container.
The call has to manage the state if an exception is called but otherwise
it will reduce the memory footprint. There will be to a RETURNING
to Sqlite which will read back values as you write.
Change-Id: I7eb49850e2c76f883a03277b31c5e713e9774c92
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Instead of coding some arguments to extraId(state) we provide now a
std::variant there extra arguments can be saved. Because it's a
std::variant it can be easlily extended by new structs. There is a new
synchronous interface too. It has an extra method for QIcon which saves
icons in an extra table. It would be even nicer if we would have a
mipmap image too. So we could do it asynchonously too but so far it works
only in the main thread.
Task-number: QDS-3579
Fixes: QDS-3584
Change-Id: If368d84d82308a91a5f4f037021e749c9ef868ed
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
You can now pass everything you can convert to a span directly and bind it
with a carray instead of using the pointer interface. This is working for
int, long long, double and null terminated C strings.
Change-Id: I274c218e2dec0f11e68576545bb78601f85462bd
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
The image cache is saving images and icon of this images in a sqlite
database. If there are no images they are generated in the backgound.
The icons are fetched by item library.
Task-number: QDS-2782
Task-number: QDS-2783
Task-number: QDS-2858
Change-Id: I5a32cccfef7f8fd8eb78902605a09f5da18ce88e
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
The bind() function takes a view, so we can't pass in a temporary.
Amends 3b0de99cf5.
Change-Id: Ic11b47688ff37699a1a56e978780a610c969d3b7
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Most of it is only silencing a warning but one is fixing a faulty test. So
writing null values should now be working.
Change-Id: If702e1fc8176a9e0ae82a5589c719d567929202b
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Session are captured by hooking in the sqlite changes. They are saved in
blobs and containing inserts, update and deletes. Because the are
semantically coupled to translactions we add a
Change-Id: Ie095558ebc50601fcaae32958ebeeb98b72d73b9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
We have done it for every getter. Now we do it only once as we ask for
the values. It simplifies the code and the test and could even improve
performance.
Change-Id: Ia7d4a33a77ec7c0a5fda548424fbf8b192f07511
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Binding by names is slower and we never used it.
Change-Id: Ia6b9b78401f8c2711be34b667ac6f08b44418773
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
So we can distingish between a null value and zero or an empty string.
Change-Id: I9122fdafdf85cf04dcf8bca7bf294be9b28ee251
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
It adds a layer if you don't know if the type is integer, float or string.
It does not handle bytearrays here because so far there is no need. There
are two classes, Sqlite::Value and Sqlite::ValueView. Value owns the
string, ValueView holds only a view the string. So there is no allocation.
It is designed to hold Utf-8 string like Sqlite but it can be easily
converted in and from QString or QVariant but mind about that this is not
free. ValueView has no constructors on perpose because it would be
ambiguous if there would be constructors for the other primitives of
the Sqlite layer like "int64", "double" and "string view".
Change-Id: Ia39364eb2fc1998e5c59fdb4316add22c748507d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
We were not reset a statement if we got an exception. There are now test
for it.
Change-Id: Ife7b4437fece9369767605ba7387bd0564c1bb8d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
We do want prevent throwing again for reset if we already have thrown an
exception but we want to throw if there was no exception.
Change-Id: Iaf9fffb872ccd579a8ccde02381b5e5d30d5c4cb
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
String view is returning simply the string pointer and the size from the
database. In that way we remove useless copies to an intermediate data
type.
Change-Id: I3354061938c52df585e91054a97c900ae4cd39b3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Tests get more reliable if the database is not shared between different
tests and the testing is speed up by not accessing the file system.
Change-Id: Ieb3c5495df4f0fae2293111949792774b01bf913
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
The database is using file path integer ids to handle file paths because
otherwise we would save many redundant data. This patch is improving it
further with the introduction of a database based file path cache. The
entries are now divided in a directory path and file name. This is quite
handy for directory based file watching.
Change-Id: I03f2e388e43f3d521d6bf8e39dfb95eb2309dc73
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
There are now only value and values methods. value returns an optional
and values are returning a vector. The result value count has now be
specified instead of the result value list.
Change-Id: I17a0741d5e838b4bf4b9486825c870ada1722584
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
We now have the very powerful write and read methods, so using the low
level interface leads only to stupid errors and prevents optimizations.
Change-Id: If2340833977935cb2d319735dee96b0bac33142b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Introducing different exceptions for different error cases.
Change-Id: I4371d1e64d9dca2a9f68dcbaa4a891c55879c1f5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
We use a name space now, so the prefix is not of much use.
Change-Id: I2b077576f94dab778add6ab2e54870f7ca18da78
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
It is now possible to read values at once.
for (auto [name, value] : statement.tupleValues<String, int>(1000, "foo", 20))
....
Change-Id: I3d4bc5218810b4620e1df625126aa490f30bbc71
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
You can now write
SqliteWriteStatement statement("UPDATE test SET name=?, number=?
WHERE rowid=?", database);
statement.write("see", 7.23, 1);
and
SqliteWriteStatement statement("UPDATE test SET name=@name, number=@number
WHERE rowid=@id", database);
statement.writeNamed("@name", "see", "@number", 7.23, "@id", 1);
This is more type safe than using variants and performant too.
Change-Id: Ie1ed2a6d326b956be5c4ec056214f3f5b1531f45
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
We only will need the utf8 optimized SmallString for the indexer database.
So we remove all other string bindings, QByteArray and QVariant.
Change-Id: I4a77901a80b26bf292fc85df535c2ccf3a8ab52f
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
We don't need the threading anymore, so we removed it. The indexer
will be run in its thread anyway, so an extra thread makes the code
only more complicated. And we added namespaces.
Change-Id: Ibcba306324763285cf653c28bb08122345e5f8da
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>