@@ -16,14 +16,12 @@ class MySQL extends MariaDB
1616{
1717 /**
1818 * Set max execution time
19- * @param int $milliseconds
20- * @param string $event
21- * @return void
19+ *
2220 * @throws DatabaseException
2321 */
2422 public function setTimeout (int $ milliseconds , string $ event = Database::EVENT_ALL ): void
2523 {
26- if (!$ this ->getSupportForTimeouts ()) {
24+ if (! $ this ->getSupportForTimeouts ()) {
2725 return ;
2826 }
2927 if ($ milliseconds <= 0 ) {
@@ -44,29 +42,28 @@ public function setTimeout(int $milliseconds, string $event = Database::EVENT_AL
4442
4543 /**
4644 * Get size of collection on disk
47- * @param string $collection
48- * @return int
45+ *
4946 * @throws DatabaseException
5047 */
5148 public function getSizeOfCollectionOnDisk (string $ collection ): int
5249 {
5350 $ collection = $ this ->filter ($ collection );
54- $ collection = $ this ->getNamespace () . '_ ' . $ collection ;
51+ $ collection = $ this ->getNamespace (). '_ ' . $ collection ;
5552 $ database = $ this ->getDatabase ();
56- $ name = $ database . '/ ' . $ collection ;
57- $ permissions = $ database . '/ ' . $ collection . '_perms ' ;
53+ $ name = $ database. '/ ' . $ collection ;
54+ $ permissions = $ database. '/ ' . $ collection. '_perms ' ;
5855
59- $ collectionSize = $ this ->getPDO ()->prepare ("
56+ $ collectionSize = $ this ->getPDO ()->prepare ('
6057 SELECT SUM(FS_BLOCK_SIZE + ALLOCATED_SIZE)
6158 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
6259 WHERE NAME = :name
63- " );
60+ ' );
6461
65- $ permissionsSize = $ this ->getPDO ()->prepare ("
62+ $ permissionsSize = $ this ->getPDO ()->prepare ('
6663 SELECT SUM(FS_BLOCK_SIZE + ALLOCATED_SIZE)
6764 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
6865 WHERE NAME = :permissions
69- " );
66+ ' );
7067
7168 $ collectionSize ->bindParam (':name ' , $ name );
7269 $ permissionsSize ->bindParam (':permissions ' , $ permissions );
@@ -76,7 +73,7 @@ public function getSizeOfCollectionOnDisk(string $collection): int
7673 $ permissionsSize ->execute ();
7774 $ size = $ collectionSize ->fetchColumn () + $ permissionsSize ->fetchColumn ();
7875 } catch (PDOException $ e ) {
79- throw new DatabaseException ('Failed to get collection size: ' . $ e ->getMessage ());
76+ throw new DatabaseException ('Failed to get collection size: ' . $ e ->getMessage ());
8077 }
8178
8279 return $ size ;
@@ -85,14 +82,8 @@ public function getSizeOfCollectionOnDisk(string $collection): int
8582 /**
8683 * Handle distance spatial queries
8784 *
88- * @param Query $query
89- * @param array<string, mixed> $binds
90- * @param string $attribute
91- * @param string $type
92- * @param string $alias
93- * @param string $placeholder
94- * @return string
95- */
85+ * @param array<string, mixed> $binds
86+ */
9687 protected function handleDistanceSpatialQueries (Query $ query , array &$ binds , string $ attribute , string $ type , string $ alias , string $ placeholder ): string
9788 {
9889 $ distanceParams = $ query ->getValues ()[0 ];
@@ -115,17 +106,19 @@ protected function handleDistanceSpatialQueries(Query $query, array &$binds, str
115106 $ operator = '< ' ;
116107 break ;
117108 default :
118- throw new DatabaseException ('Unknown spatial query method: ' . $ query ->getMethod ());
109+ throw new DatabaseException ('Unknown spatial query method: ' . $ query ->getMethod ());
119110 }
120111
121112 if ($ useMeters ) {
122- $ attr = "ST_SRID( {$ alias }. {$ attribute }, " . Database::DEFAULT_SRID . " ) " ;
113+ $ attr = "ST_SRID( {$ alias }. {$ attribute }, " . Database::DEFAULT_SRID . ' ) ' ;
123114 $ geom = $ this ->getSpatialGeomFromText (": {$ placeholder }_0 " , null );
115+
124116 return "ST_Distance( {$ attr }, {$ geom }, 'metre') {$ operator } : {$ placeholder }_1 " ;
125117 }
126118 // need to use srid 0 because of geometric distance
127- $ attr = "ST_SRID( {$ alias }. {$ attribute }, " . 0 . " ) " ;
119+ $ attr = "ST_SRID( {$ alias }. {$ attribute }, " . 0 .' ) ' ;
128120 $ geom = $ this ->getSpatialGeomFromText (": {$ placeholder }_0 " , 0 );
121+
129122 return "ST_Distance( {$ attr }, {$ geom }) {$ operator } : {$ placeholder }_1 " ;
130123 }
131124
@@ -139,7 +132,7 @@ public function getSupportForIndexArray(): bool
139132
140133 public function getSupportForCastIndexArray (): bool
141134 {
142- if (!$ this ->getSupportForIndexArray ()) {
135+ if (! $ this ->getSupportForIndexArray ()) {
143136 return false ;
144137 }
145138
@@ -173,29 +166,25 @@ protected function processException(PDOException $e): \Exception
173166
174167 return parent ::processException ($ e );
175168 }
169+
176170 /**
177171 * Does the adapter includes boundary during spatial contains?
178- *
179- * @return bool
180172 */
181173 public function getSupportForBoundaryInclusiveContains (): bool
182174 {
183175 return false ;
184176 }
177+
185178 /**
186179 * Does the adapter support order attribute in spatial indexes?
187- *
188- * @return bool
189- */
180+ */
190181 public function getSupportForSpatialIndexOrder (): bool
191182 {
192183 return false ;
193184 }
194185
195186 /**
196187 * Does the adapter support calculating distance(in meters) between multidimension geometry(line, polygon,etc)?
197- *
198- * @return bool
199188 */
200189 public function getSupportForDistanceBetweenMultiDimensionGeometryInMeters (): bool
201190 {
@@ -204,51 +193,52 @@ public function getSupportForDistanceBetweenMultiDimensionGeometryInMeters(): bo
204193
205194 /**
206195 * Spatial type attribute
207- */
196+ */
208197 public function getSpatialSQLType (string $ type , bool $ required ): string
209198 {
210199 switch ($ type ) {
211200 case Database::VAR_POINT :
212201 $ type = 'POINT SRID 4326 ' ;
213- if (!$ this ->getSupportForSpatialIndexNull ()) {
202+ if (! $ this ->getSupportForSpatialIndexNull ()) {
214203 if ($ required ) {
215204 $ type .= ' NOT NULL ' ;
216205 } else {
217206 $ type .= ' NULL ' ;
218207 }
219208 }
209+
220210 return $ type ;
221211
222212 case Database::VAR_LINESTRING :
223213 $ type = 'LINESTRING SRID 4326 ' ;
224- if (!$ this ->getSupportForSpatialIndexNull ()) {
214+ if (! $ this ->getSupportForSpatialIndexNull ()) {
225215 if ($ required ) {
226216 $ type .= ' NOT NULL ' ;
227217 } else {
228218 $ type .= ' NULL ' ;
229219 }
230220 }
231- return $ type ;
232221
222+ return $ type ;
233223
234224 case Database::VAR_POLYGON :
235225 $ type = 'POLYGON SRID 4326 ' ;
236- if (!$ this ->getSupportForSpatialIndexNull ()) {
226+ if (! $ this ->getSupportForSpatialIndexNull ()) {
237227 if ($ required ) {
238228 $ type .= ' NOT NULL ' ;
239229 } else {
240230 $ type .= ' NULL ' ;
241231 }
242232 }
233+
243234 return $ type ;
244235 }
236+
245237 return '' ;
246238 }
247239
248240 /**
249241 * Does the adapter support spatial axis order specification?
250- *
251- * @return bool
252242 */
253243 public function getSupportForSpatialAxisOrder (): bool
254244 {
@@ -263,8 +253,6 @@ public function getSupportForObjectIndexes(): bool
263253 /**
264254 * Get the spatial axis order specification string for MySQL
265255 * MySQL with SRID 4326 expects lat-long by default, but our data is in long-lat format
266- *
267- * @return string
268256 */
269257 protected function getSpatialAxisOrderSpec (): string
270258 {
@@ -273,8 +261,6 @@ protected function getSpatialAxisOrderSpec(): string
273261
274262 /**
275263 * Adapter supports optional spatial attributes with existing rows.
276- *
277- * @return bool
278264 */
279265 public function getSupportForOptionalSpatialAttributeWithExistingRows (): bool
280266 {
@@ -285,30 +271,21 @@ public function getSupportForOptionalSpatialAttributeWithExistingRows(): bool
285271 * Get SQL expression for operator
286272 * Override for MySQL-specific operator implementations
287273 *
288- * @param string $column
289- * @param \Utopia\Database\Operator $operator
290- * @param array<string, mixed> $binds
291- * @return ?string
274+ * @param array<string, mixed> $binds
292275 */
293- protected function getOperatorSQL (string $ column , \ Utopia \ Database \ Operator $ operator , array &$ binds ): ?string
276+ protected function getOperatorSQL (string $ column , Operator $ operator , array &$ binds ): ?string
294277 {
295278 $ quotedColumn = $ this ->quote ($ column );
296279 $ method = $ operator ->getMethod ();
297280 $ values = $ operator ->getValues ();
298281
299282 switch ($ method ) {
300- case Operator::TYPE_ARRAY_APPEND :
301- if (\count ($ values ) > Operator::MAX_ARRAY_OPERATOR_SIZE ) {
302- throw new DatabaseException ("Array size " . \count ($ values ) . " exceeds maximum allowed size of " . Operator::MAX_ARRAY_OPERATOR_SIZE . " for array operations " );
303- }
304- $ bindKey = $ this ->registerOperatorBind ($ binds , json_encode ($ values ));
283+ case Operator::TYPE_ARRAY_APPEND : $ bindKey = $ this ->registerOperatorBind ($ binds , json_encode ($ values ));
284+
305285 return "{$ quotedColumn } = JSON_MERGE_PRESERVE(IFNULL( {$ quotedColumn }, JSON_ARRAY()), : $ bindKey) " ;
306286
307- case Operator::TYPE_ARRAY_PREPEND :
308- if (\count ($ values ) > Operator::MAX_ARRAY_OPERATOR_SIZE ) {
309- throw new DatabaseException ("Array size " . \count ($ values ) . " exceeds maximum allowed size of " . Operator::MAX_ARRAY_OPERATOR_SIZE . " for array operations " );
310- }
311- $ bindKey = $ this ->registerOperatorBind ($ binds , json_encode ($ values ));
287+ case Operator::TYPE_ARRAY_PREPEND : $ bindKey = $ this ->registerOperatorBind ($ binds , json_encode ($ values ));
288+
312289 return "{$ quotedColumn } = JSON_MERGE_PRESERVE(: $ bindKey, IFNULL( {$ quotedColumn }, JSON_ARRAY())) " ;
313290
314291 case Operator::TYPE_ARRAY_UNIQUE :
0 commit comments