aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/DB/Types.php
blob: 969ec5e6611292e5e796c36a1fb7595e87d8eb56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCP\DB;

/**
 * Database types supported by Nextcloud's DBs
 *
 * Use these constants instead of \Doctrine\DBAL\Types\Type or \Doctrine\DBAL\Types\Types
 *
 * @since 21.0.0
 */
final class Types {
	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const BIGINT = 'bigint';

	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const BINARY = 'binary';

	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const BLOB = 'blob';

	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const BOOLEAN = 'boolean';

	/**
	 * A datetime instance with only the date set.
	 * This will be (de)serialized into a \DateTime instance,
	 * it is recommended to instead use the `DATE_IMMUTABLE` instead.
	 *
	 * Warning: When deserialized the timezone will be set to UTC.
	 * @var string
	 * @since 21.0.0
	 */
	public const DATE = 'date';

	/**
	 * An immutable datetime instance with only the date set.
	 * This will be (de)serialized into a \DateTimeImmutable instance,
	 * It is recommended to use this over the `DATE` type because
	 * out `Entity` class works detecting changes through the setter,
	 * changes on mutable objects can not be detected.
	 *
	 * Warning: When deserialized the timezone will be set to UTC.
	 * @var string
	 * @since 31.0.0
	 */
	public const DATE_IMMUTABLE = 'date_immutable';

	/**
	 * A datetime instance with date and time support.
	 * This will be (de)serialized into a \DateTime instance,
	 * it is recommended to instead use the `DATETIME_IMMUTABLE` instead.
	 *
	 * Warning: When deserialized the timezone will be set to UTC.
	 * @var string
	 * @since 21.0.0
	 */
	public const DATETIME = 'datetime';

	/**
	 * An immutable datetime instance with date and time set.
	 * This will be (de)serialized into a \DateTimeImmutable instance,
	 * It is recommended to use this over the `DATETIME` type because
	 * out `Entity` class works detecting changes through the setter,
	 * changes on mutable objects can not be detected.
	 *
	 * Warning: When deserialized the timezone will be set to UTC.
	 * @var string
	 * @since 31.0.0
	 */
	public const DATETIME_IMMUTABLE = 'datetime_immutable';


	/**
	 * A datetime instance with timezone support
	 * This will be (de)serialized into a \DateTime instance,
	 * it is recommended to instead use the `DATETIME_TZ_IMMUTABLE` instead.
	 *
	 * @var string
	 * @since 31.0.0
	 */
	public const DATETIME_TZ = 'datetimetz';

	/**
	 * An immutable timezone aware datetime instance with date and time set.
	 * This will be (de)serialized into a \DateTimeImmutable instance,
	 * It is recommended to use this over the `DATETIME_TZ` type because
	 * out `Entity` class works detecting changes through the setter,
	 * changes on mutable objects can not be detected.
	 *
	 * @var string
	 * @since 31.0.0
	 */
	public const DATETIME_TZ_IMMUTABLE = 'datetimetz_immutable';

	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const DECIMAL = 'decimal';

	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const FLOAT = 'float';

	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const INTEGER = 'integer';

	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const SMALLINT = 'smallint';

	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const STRING = 'string';

	/**
	 * @var string
	 * @since 21.0.0
	 */
	public const TEXT = 'text';

	/**
	 * A datetime instance with only the time set.
	 * This will be (de)serialized into a \DateTime instance,
	 * it is recommended to instead use the `TIME_IMMUTABLE` instead.
	 *
	 * Warning: When deserialized the timezone will be set to UTC.
	 * @var string
	 * @since 21.0.0
	 */
	public const TIME = 'time';

	/**
	 * A datetime instance with only the time set.
	 * This will be (de)serialized into a \DateTime instance.
	 *
	 * It is recommended to use this over the `DATETIME_TZ` type because
	 * out `Entity` class works detecting changes through the setter,
	 * changes on mutable objects can not be detected.
	 *
	 * @var string
	 * @since 31.0.0
	 */
	public const TIME_IMMUTABLE = 'time_immutable';

	/**
	 * @var string
	 * @since 24.0.0
	 */
	public const JSON = 'json';
}