Commit Graph

75 Commits

Author SHA1 Message Date
Carl Schwan
c04c320e61 fix(Entity): Add type for getUpdatedField in doc
The method is very confusing as the updated fields are the keys of the
returned array.

Signed-off-by: Carl Schwan <carlschwan@kde.org>
2026-01-28 15:46:02 +01:00
Carl Schwan
81a21fb718 refactor(entity): Don't type id
Some apps overwrite this and this breaks them.

Signed-off-by: Carl Schwan <carlschwan@kde.org>
2026-01-09 10:19:34 +01:00
Joas Schilling
fe393c5dbf fix(snowflake): Fix generateId() call for SnowflakeEntity
Signed-off-by: Joas Schilling <coding@schilljs.com>
2026-01-07 15:39:09 +01:00
Joas Schilling
2bd2cc71e5 fix(snowflake): Allow SnowflakeAware to overwrite the field types
Signed-off-by: Joas Schilling <coding@schilljs.com>
2026-01-07 14:06:18 +01:00
Carl Schwan
693a2263cc fix(entity): Do not call getId when inserting and $id is null
Otherwise this breaks some existing code, in particular PublicKeyToken

Signed-off-by: Carl Schwan <carlschwan@kde.org>
2026-01-06 15:42:03 +01:00
Carl Schwan
7c1a8a4060 feat: Adapt a bit the snowflake ids API
- Rename setId() -> generateId() in SnowflakeAwareEntity

Signed-off-by: Carl Schwan <carlschwan@kde.org>
2026-01-06 12:57:17 +01:00
Anna Larch
a100ede789 feat: extend Entity and adjust QBMapper to support Snowflake IDs
Signed-off-by: Anna Larch <anna@nextcloud.com>
2026-01-06 12:57:17 +01:00
Carl Schwan
336cc3fa35 feat(Db): Use SnowflakeId for previews
Allow to get an id for the storing the preview on disk before inserting
the preview on the DB.

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
2025-10-28 17:50:03 +01:00
Carl Schwan
bba9667882 perf(preview): Adapt BackgroundCleanupJob to new previews table
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
2025-10-06 13:37:15 +02:00
Ferdinand Thiessen
5981b7eb51 chore: apply new CSFixer rules
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>

# Conflicts:
#	apps/settings/lib/SetupChecks/PhpOpcacheSetup.php
2025-07-01 16:26:50 +02:00
Anna Larch
1562db80b1 fix: remove typing and return type
Signed-off-by: Anna Larch <anna@nextcloud.com>
2025-01-23 18:34:19 +01:00
provokateurin
2c65d0c0d1 fix(QBMapper): Fix findEntities() return type to be list<T>
Signed-off-by: provokateurin <kate@provokateurin.de>
2024-11-06 16:31:39 +01:00
Joas Schilling
54c3aa3f99 fix(entity): Fix mapping of old/sub-types to actually supported database types
Signed-off-by: Joas Schilling <coding@schilljs.com>
2024-10-23 09:22:05 +02:00
Ferdinand Thiessen
0e54c2bd43 fix: Adjust Entity types
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2024-10-17 18:31:44 +02:00
Ferdinand Thiessen
db94e10af0 fix: Prevent breaking change in IQueryBuilder
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2024-10-17 18:31:44 +02:00
Ferdinand Thiessen
ee02e3246d feat(AppFramework): Add full support for date / time / datetime columns
This adds support for all Doctrine supported types, for the column types only the immutable variants needed to be added.
But especially those types are the important ones, as our **Entity** class works by detecting changes through setters.
Meaning if it is mutable, changes like `$entity->date->modfiy()` can not be detected, so the immutable types make more sense here.

Similar the parameter types needed to be added.

`Enity` and `QBMapper` needed to be adjusted so they support (auto map) those types, required when insert or update an entity.

Also added more tests, especially to make sure the mapper really serializes the values correctly.

Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de>
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2024-10-17 18:31:42 +02:00
provokateurin
9836e9b164 chore(deps): Update nextcloud/coding-standard to v1.3.1
Signed-off-by: provokateurin <kate@provokateurin.de>
2024-09-19 14:21:20 +02:00
Kate
8a32881633 Merge pull request #48008 from nextcloud/fix/entity/strict-types 2024-09-16 11:08:35 +02:00
Anna Larch
6c36c54dc6 feat(db): switch from settype to casts
Signed-off-by: Anna Larch <anna@nextcloud.com>
2024-09-15 19:26:58 +02:00
provokateurin
247b1dd70e fix(Entity): Fix magic setter call for custom strong typed setters
Signed-off-by: provokateurin <kate@provokateurin.de>
2024-09-15 15:14:54 +02:00
Daniel Kesselberg
af6de04e9e style: update codestyle for coding-standard 1.2.3
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2024-08-25 19:34:58 +02:00
Julius Härtl
2fb0ca9cf7 feat: Add yieldEntities wrapper for entity mapping in QBMapper
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2024-06-24 09:15:58 +02:00
Andy Scherzinger
dae7c159f7 chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-05-24 13:11:22 +02:00
Côme Chilliet
ec5133b739 fix: Apply new coding standard to all files
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2024-04-02 14:16:21 +02:00
Faraz Samapoor
bf38c0a3d1 Refactors "strpos" calls in lib/public to improve code readability.
Signed-off-by: Faraz Samapoor <fsamapoor@gmail.com>
2023-06-05 11:14:52 +02:00
Julius Härtl
050c6d53b3 enh: Provide atomicRetry method to retry transactions if possible
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2023-05-16 08:13:20 +02:00
Daniel Kesselberg
eecdb62e92 fix: add workaround for oci and limit queries
DBAL uses a helper column "doctrine_rownum" for top-n queries

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2023-05-02 14:26:28 +02:00
Ferdinand Thiessen
bdbff2181e fix: Allow to catch IMapperException by implementing Throwable
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
2023-04-17 16:05:10 +00:00
jld3103
b153340b62 Add type hints for mappers
Signed-off-by: jld3103 <jld3103yt@gmail.com>
2023-04-07 09:49:42 +02:00
Côme Chilliet
f5c361cf44 composer run cs:fix
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-01-20 11:45:08 +01:00
Côme Chilliet
e91457d9cd Improve typing in Entity.php
Removing @method in Entity brings even more errors.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-01-20 11:22:09 +01:00
Roeland Jago Douma
60ee874485 Remove long depreated AppFramework/Db/Mapper
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
2022-10-10 08:18:32 +02:00
Thomas Citharel
1d30fb7852 Fix reading blob data as resource
PostgreSQL returns data as resource when using IQueryBuilder::PARAM_LOB
(which is used for QBMapper).

Previously we just converted this resource using settype, which produced
things like "Resource id #14" instead of the actual resource data.

Now we read the stream correctly if the returned data is a resource

See context at #22472

Fixes #22439

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2022-07-25 09:45:47 +02:00
Christoph Wurst
1cd05a06fa Always free the DB result in QBMapper::findEntities
Without this patch it only happened if the code ran through without any
errors. Now the result is also freed in the case of an error.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2022-05-12 09:51:37 +02:00
Carl Schwan
7817845538 Add a metadata service to store file metadata
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-04-13 14:06:29 +02:00
Christoph Wurst
cb252c5591 Add Transactional trait for atomic DB operations
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2022-02-17 09:58:41 +01:00
Christoph Wurst
3e078ffa1b Deprecate entity slugs
They are only used a single time in the whole Nextcloud Github
organization. We can inline the code there and slim down the public API.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-12-14 09:50:29 +01:00
John Molakvoæ (skjnldsv)
215aef3cbd Update php licenses
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2021-06-04 22:02:41 +02:00
Anna Larch
8fcb3f33c8 Add DB exception throws tag to QBMapper PHPDoc
Signed-off-by: Anna Larch <anna@nextcloud.com>
2021-05-26 15:12:41 +02:00
Morris Jobke
ed2d6eee1e Merge pull request #26848 from nextcloud/bugfix/noid/add-datetime-support-to-qbmapper
Add datetime support to QBMapper
2021-05-07 16:02:53 +02:00
Christoph Wurst
865661ed75 Rename IQueryBuilder::executeUpdate to IQueryBuilder::executeStatement
Because executeUpdate wasn't a great name. And in DBAL they also use
executeStatement more consistently now.

Ref https://github.com/doctrine/dbal/issues/4607

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-05-05 10:31:54 +02:00
Joas Schilling
5c4c527245 Add datetime support to QBMapper
Signed-off-by: Joas Schilling <coding@schilljs.com>
2021-05-01 11:59:19 +02:00
Joas Schilling
25d11b5197 Fix constraint violation detection in QB Mapper
Signed-off-by: Joas Schilling <coding@schilljs.com>
2021-04-16 10:12:17 +02:00
Christoph Wurst
0d8b3baf61 Use executeQuery and executeUpdate in the QBMapper
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-03-18 15:40:18 +01:00
Roeland Jago Douma
69b26c73f3 Fix some redundant casts
Happier psalm

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
2021-03-08 08:51:08 +01:00
Christoph Wurst
a1b351036c Add template typing to the QBMapper
The QBMapper is kind of a generic type, though this concept does not
exist in php. Hence you have a lot of type coercion in subtypes (mappers
in the individual apps) because you suddenly don't expect an Entity[]
but your specific type.

Luckily Psalm lets us type those. Then in the subclass you can
psalm-implement the mapper with a concrete type and psalm will do all
the magic to ensure types are used correctly.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-10-12 11:10:08 +02:00
Christoph Wurst
d9015a8c94 Format code to a single space around binary operators
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-10-05 20:25:24 +02:00
Morris Jobke
99c9423766 Remove @suppress SqlInjectionChecker
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
2020-09-16 15:53:56 +02:00
Christoph Wurst
3bc54bfd06 Fix writing BLOBs to postgres with recent contacts interaction
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-08-28 14:30:33 +02:00
Christoph Wurst
cb057829f7 Update license headers for 19
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-04-29 11:57:22 +02:00