Skip to content

Commit 860867a

Browse files
authored
Merge pull request #63866 from nextcloud/chore-add-column-type-guid
feat(db): Add column type guid
2 parents 4da8f5a + b117761 commit 860867a

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/public/AppFramework/ORM/Repository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private function hydrateRow(string $entityClass, mixed $row): object {
9898
ColumnType::Bigint, ColumnType::Smallint, ColumnType::Integer => (int)$value,
9999
ColumnType::Float => (float)$value,
100100
ColumnType::Boolean => (bool)$value,
101-
ColumnType::Binary, ColumnType::Decimal, ColumnType::Text, ColumnType::String => (string)$value,
101+
ColumnType::Binary, ColumnType::Decimal, ColumnType::Guid, ColumnType::Text, ColumnType::String => (string)$value,
102102
ColumnType::Time, ColumnType::Date, ColumnType::Datetime, ColumnType::DatetimeTz => $value instanceof \DateTime
103103
? $value
104104
: new \DateTime((string)$value),

lib/public/DB/Schema/ColumnType.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ enum ColumnType: string {
164164
*/
165165
case Json = 'json';
166166

167+
/**
168+
* If you want to store a GUID, you should consider using this type, as some database vendors have a native data type for this kind of data which offers the most efficient way to store it.
169+
* For vendors that do not support this type natively, this type is mapped to the string type internally.
170+
* Values retrieved from the database are always converted to PHP's string type or null if no data is present.
171+
*
172+
* @since 35.0.0
173+
*/
174+
case Guid = 'guid';
175+
167176
/**
168177
* @since 35.0.0
169178
*/

lib/public/DB/Types.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,13 @@ final class Types {
178178
* It is recommended to use a simple STRING field and handle JSON within PHP
179179
*/
180180
public const JSON = 'json';
181+
182+
/**
183+
* If you want to store a GUID, you should consider using this type, as some database vendors have a native data type for this kind of data which offers the most efficient way to store it.
184+
* For vendors that do not support this type natively, this type is mapped to the string type internally.
185+
* Values retrieved from the database are always converted to PHP's string type or null if no data is present.
186+
*
187+
* @since 35.0.0
188+
*/
189+
public const GUID = 'guid';
181190
}

0 commit comments

Comments
 (0)