@@ -3487,7 +3487,7 @@ public function getDocument(string $collection, string $id, array $queries = [],
34873487 $ this ->checkQueriesType ($ queries );
34883488
34893489 if ($ this ->validate ) {
3490- $ validator = new DocumentValidator ($ attributes );
3490+ $ validator = new DocumentValidator ($ attributes, $ this -> adapter -> getSupportForAttributes () );
34913491 if (!$ validator ->isValid ($ queries )) {
34923492 throw new QueryException ($ validator ->getDescription ());
34933493 }
@@ -5019,6 +5019,7 @@ public function updateDocuments(
50195019 $ this ->maxQueryValues ,
50205020 $ this ->adapter ->getMinDateTime (),
50215021 $ this ->adapter ->getMaxDateTime (),
5022+ $ this ->adapter ->getSupportForAttributes ()
50225023 );
50235024
50245025 if (!$ validator ->isValid ($ queries )) {
@@ -5892,24 +5893,25 @@ public function increaseDocumentAttribute(
58925893 }
58935894
58945895 $ collection = $ this ->silent (fn () => $ this ->getCollection ($ collection ));
5896+ if ($ this ->adapter ->getSupportForAttributes ()) {
5897+ $ attr = \array_filter ($ collection ->getAttribute ('attributes ' , []), function ($ a ) use ($ attribute ) {
5898+ return $ a ['$id ' ] === $ attribute ;
5899+ });
58955900
5896- $ attr = \array_filter ($ collection ->getAttribute ('attributes ' , []), function ($ a ) use ($ attribute ) {
5897- return $ a ['$id ' ] === $ attribute ;
5898- });
5899-
5900- if (empty ($ attr )) {
5901- throw new NotFoundException ('Attribute not found ' );
5902- }
5901+ if (empty ($ attr )) {
5902+ throw new NotFoundException ('Attribute not found ' );
5903+ }
59035904
5904- $ whiteList = [
5905- self ::VAR_INTEGER ,
5906- self ::VAR_FLOAT
5907- ];
5905+ $ whiteList = [
5906+ self ::VAR_INTEGER ,
5907+ self ::VAR_FLOAT
5908+ ];
59085909
5909- /** @var Document $attr */
5910- $ attr = \end ($ attr );
5911- if (!\in_array ($ attr ->getAttribute ('type ' ), $ whiteList ) || $ attr ->getAttribute ('array ' )) {
5912- throw new TypeException ('Attribute must be an integer or float and can not be an array. ' );
5910+ /** @var Document $attr */
5911+ $ attr = \end ($ attr );
5912+ if (!\in_array ($ attr ->getAttribute ('type ' ), $ whiteList ) || $ attr ->getAttribute ('array ' )) {
5913+ throw new TypeException ('Attribute must be an integer or float and can not be an array. ' );
5914+ }
59135915 }
59145916
59155917 $ document = $ this ->withTransaction (function () use ($ collection , $ id , $ attribute , $ value , $ max ) {
@@ -5990,25 +5992,27 @@ public function decreaseDocumentAttribute(
59905992
59915993 $ collection = $ this ->silent (fn () => $ this ->getCollection ($ collection ));
59925994
5993- $ attr = \array_filter ($ collection ->getAttribute ('attributes ' , []), function ($ a ) use ($ attribute ) {
5994- return $ a ['$id ' ] === $ attribute ;
5995- });
5995+ if ($ this ->adapter ->getSupportForAttributes ()) {
5996+ $ attr = \array_filter ($ collection ->getAttribute ('attributes ' , []), function ($ a ) use ($ attribute ) {
5997+ return $ a ['$id ' ] === $ attribute ;
5998+ });
59965999
5997- if (empty ($ attr )) {
5998- throw new NotFoundException ('Attribute not found ' );
5999- }
6000+ if (empty ($ attr )) {
6001+ throw new NotFoundException ('Attribute not found ' );
6002+ }
60006003
6001- $ whiteList = [
6002- self ::VAR_INTEGER ,
6003- self ::VAR_FLOAT
6004- ];
6004+ $ whiteList = [
6005+ self ::VAR_INTEGER ,
6006+ self ::VAR_FLOAT
6007+ ];
60056008
6006- /**
6007- * @var Document $attr
6008- */
6009- $ attr = \end ($ attr );
6010- if (!\in_array ($ attr ->getAttribute ('type ' ), $ whiteList ) || $ attr ->getAttribute ('array ' )) {
6011- throw new TypeException ('Attribute must be an integer or float and can not be an array. ' );
6009+ /**
6010+ * @var Document $attr
6011+ */
6012+ $ attr = \end ($ attr );
6013+ if (!\in_array ($ attr ->getAttribute ('type ' ), $ whiteList ) || $ attr ->getAttribute ('array ' )) {
6014+ throw new TypeException ('Attribute must be an integer or float and can not be an array. ' );
6015+ }
60126016 }
60136017
60146018 $ document = $ this ->withTransaction (function () use ($ collection , $ id , $ attribute , $ value , $ min ) {
@@ -6563,7 +6567,8 @@ public function deleteDocuments(
65636567 $ this ->adapter ->getIdAttributeType (),
65646568 $ this ->maxQueryValues ,
65656569 $ this ->adapter ->getMinDateTime (),
6566- $ this ->adapter ->getMaxDateTime ()
6570+ $ this ->adapter ->getMaxDateTime (),
6571+ $ this ->adapter ->getSupportForAttributes ()
65676572 );
65686573
65696574 if (!$ validator ->isValid ($ queries )) {
@@ -6992,6 +6997,7 @@ public function count(string $collection, array $queries = [], ?int $max = null)
69926997 $ this ->maxQueryValues ,
69936998 $ this ->adapter ->getMinDateTime (),
69946999 $ this ->adapter ->getMaxDateTime (),
7000+ $ this ->adapter ->getSupportForAttributes ()
69957001 );
69967002 if (!$ validator ->isValid ($ queries )) {
69977003 throw new QueryException ($ validator ->getDescription ());
@@ -7056,6 +7062,7 @@ public function sum(string $collection, string $attribute, array $queries = [],
70567062 $ this ->maxQueryValues ,
70577063 $ this ->adapter ->getMinDateTime (),
70587064 $ this ->adapter ->getMaxDateTime (),
7065+ $ this ->adapter ->getSupportForAttributes ()
70597066 );
70607067 if (!$ validator ->isValid ($ queries )) {
70617068 throw new QueryException ($ validator ->getDescription ());
@@ -7460,10 +7467,11 @@ private function validateSelections(Document $collection, array $queries): array
74607467 $ keys [] = $ attribute ['key ' ] ?? $ attribute ['$id ' ];
74617468 }
74627469 }
7463-
7464- $ invalid = \array_diff ($ selections , $ keys );
7465- if (!empty ($ invalid ) && !\in_array ('* ' , $ invalid )) {
7466- throw new QueryException ('Cannot select attributes: ' . \implode (', ' , $ invalid ));
7470+ if ($ this ->adapter ->getSupportForAttributes ()) {
7471+ $ invalid = \array_diff ($ selections , $ keys );
7472+ if (!empty ($ invalid ) && !\in_array ('* ' , $ invalid )) {
7473+ throw new QueryException ('Cannot select attributes: ' . \implode (', ' , $ invalid ));
7474+ }
74677475 }
74687476
74697477 $ selections = \array_merge ($ selections , $ relationshipSelections );
0 commit comments