You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_31.rst
+18-1Lines changed: 18 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -70,7 +70,8 @@ Added APIs
70
70
71
71
- It is now possible to download folders as zip or tar archives using the WebDAV backend using :code:`GET` requests.
72
72
See the relevant :ref:`endpoint documentation<webdav-download-folders>`.
73
-
- ``OCP\SetupCheck\CheckServerResponseTrait`` was added to ease implementing custom :ref:`setup checks<setup-checks>` which need to check HTTP calls to the the server itself.
73
+
- ``OCP\SetupCheck\CheckServerResponseTrait`` was added to ease implementing custom :ref:`setup checks<setup-checks>`
74
+
which need to check HTTP calls to the the server itself.
74
75
75
76
Changed APIs
76
77
^^^^^^^^^^^^
@@ -82,12 +83,28 @@ Changed APIs
82
83
#. Add all parameter types to your implementation once Nextcloud 31 is the lowest supported version.
83
84
84
85
- The Nextcloud implementation of the ``log`` method of ``Psr\Log\LoggerInterface`` now supports ``Psr\Log\LogLevel`` as log level parameter.
86
+
- The ``OCP\DB\QueryBuilder\IQueryBuilder`` now supports more date / time related parameter types:
87
+
88
+
- ``PARAM_DATE_MUTABLE`` and ``PARAM_DATE_IMMUTABLE`` for passing a ``\DateTime`` (``\DateTimeImmutable`` respectively) instance when only interested in the date part.
89
+
- ``PARAM_TIME_MUTABLE`` and ``PARAM_TIME_IMMUTABLE`` to pass a ``\DateTime`` (``\DateTimeImmutable`` respectively) instance when only interested in the time part.
90
+
- ``PARAM_DATETIME_MUTABLE`` and ``PARAM_DATETIME_IMMUTABLE`` to pass a ``\DateTime`` (``\DateTimeImmutable`` respectively) instance without handling of the timezone.
91
+
- ``PARAM_DATETIME_TZ_MUTABLE`` and ``PARAM_DATETIME_TZ_IMMUTABLE`` to pass a ``\DateTime`` (``\DateTimeImmutable`` respectively) instance with handling of the timezone.
92
+
93
+
- The ``OCP\\DB\\Types`` now support more date and time related types for usage with the ``Entity``:
94
+
95
+
- ``DATE_IMMUTABLE`` for fields that will (de)serialized as ``\DateTimeImmutable`` instances with only the date part set.
96
+
- ``TIME_IMMUTABLE`` for fields that will (de)serialized as ``\DateTimeImmutable`` instances with only the time part set.
97
+
- ``DATETIME_IMMUTABLE`` for fields that will (de)serialized as ``\DateTimeImmutable`` instances with both the time part set but without timezone information.
98
+
- ``DATETIME_TZ`` for fields that will (de)serialized as ``\DateTime`` instances with both the time part set and with timezone information.
99
+
- ``DATETIME_TZ_IMMUTABLE`` for fields that will (de)serialized as ``\DateTimeImmutable`` instances with both the time part set and with timezone information.
85
100
86
101
Deprecated APIs
87
102
^^^^^^^^^^^^^^^
88
103
89
104
- The ``/s/{token}/download`` endpoint for downloading public shares is deprecated.
90
105
Instead use the Nextcloud provided :ref:`WebDAV endpoint<webdav-download-folders>`.
106
+
- ``OCP\DB\QueryBuilder\IQueryBuilder::PARAM_DATE`` is deprecated in favor of ``PARAM_DATETIME_MUTABLE``
107
+
to make clear that this type also includes the time part of a date time instance.
Copy file name to clipboardExpand all lines: developer_manual/basics/storage/database.rst
+29-13Lines changed: 29 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -207,7 +207,9 @@ or::
207
207
Entities
208
208
--------
209
209
210
-
Entities are data objects that carry all the table's information for one row. Every Entity has an **id** field by default that is set to the integer type. Table rows are mapped from lower case and underscore separated names to *lowerCamelCase* attributes:
210
+
Entities are data objects that carry all the table's information for one row.
211
+
Every Entity has an **id** field by default that is set to the integer type.
212
+
Table rows are mapped from lower case and underscore separated names to *lowerCamelCase* attributes:
211
213
212
214
* **Table column name**: phone_number
213
215
* **Property name**: phoneNumber
@@ -220,6 +222,7 @@ Entities are data objects that carry all the table's information for one row. Ev
220
222
namespace OCA\MyApp\Db;
221
223
222
224
use OCP\AppFramework\Db\Entity;
225
+
use OCP\DB\Types;
223
226
224
227
class Author extends Entity {
225
228
@@ -229,24 +232,35 @@ Entities are data objects that carry all the table's information for one row. Ev
229
232
230
233
public function __construct() {
231
234
// add types in constructor
232
-
$this->addType('stars', 'integer');
235
+
$this->addType('stars', Types::INTEGER);
236
+
// other fields are implicitly `Types::STRING`
233
237
}
234
238
}
235
239
236
240
Types
237
241
^^^^^
238
242
239
-
The following properties should be annotated by types, to not only assure that the types are converted correctly for storing them in the database (e.g. PHP casts false to the empty string which fails on PostgreSQL) but also for casting them when they are retrieved from the database.
243
+
The following properties should be annotated by types, to not only assure that the types are converted correctly for storing them in the database
244
+
(e.g. PHP casts false to the empty string which fails on PostgreSQL) but also for casting them when they are retrieved from the database.
240
245
241
-
The following types can be added for a field:
246
+
The following types (as part of ``OCP\DB\Types``) can be added for a field:
242
247
243
-
* ``integer``
244
-
* ``float``
245
-
* ``boolean``
246
-
* ``string`` - For text and string columns
247
-
* ``blob`` - For binary data or strings longer than
248
-
* ``json`` - JSON data is automatically decoded on reading
* ``Types::JSON`` - JSON data is automatically decoded on reading
254
+
* For time and/or dates, provided as ``\DateTimeImmutable`` objects, the following types can be used:
255
+
256
+
* ``Types::DATE_IMMUTABLE`` - only the date is stored (without timezone)
257
+
* ``Types::TIME_IMMUTABLE`` - only the time is stored (without timezone)
258
+
* ``Types::DATETIME_IMMUTABLE`` - date and time are stored, but without timezone
259
+
* ``Types::DATETIME_TZ_IMMUTABLE`` - date and time are stored with timezone information
260
+
261
+
* ``Types::DATE``, ``Types::TIME``, ``Types::DATETIME``, ``Types::DATETIME_TZ`` - similar as the immutable variants, but these will be provided as ``\DateTime`` objects.
262
+
It is recommended to use the immutable variants as the internal state tracking of the ``Entity`` class only work with re-assignments,
263
+
so any changes on this mutable types will not be tracked and the update method will not write back the changes to the database.
250
264
251
265
.. _database-entity-attribute-access:
252
266
@@ -346,14 +360,16 @@ You can add attributes to an entity class that do not map to a database column.
346
360
}
347
361
}
348
362
349
-
It is important to define getters and setters for any transient attributes. Do not use the :ref:`magic getters and setters<database-entity-attribute-access>` of attributes that map to database columns.
363
+
It is important to define getters and setters for any transient attributes.
364
+
Do not use the :ref:`magic getters and setters<database-entity-attribute-access>` of attributes that map to database columns.
350
365
351
366
Slugs
352
367
^^^^^
353
368
354
369
.. deprecated:: 24
355
370
356
-
Slugs are used to identify resources in the URL by a string rather than integer id. Since the URL allows only certain values, the entity base class provides a slugify method for it:
371
+
Slugs are used to identify resources in the URL by a string rather than integer id.
372
+
Since the URL allows only certain values, the entity base class provides a slugify method for it:
0 commit comments