Skip to content

Commit dfbd096

Browse files
committed
Renamed array_set to array_replace_at
1 parent 150cd9b commit dfbd096

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

features/phpcr_query_update.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Feature: Execute a a raw UPDATE query in JCR_SQL2
6262
And the node at "/cms/articles/article1" should have the property "tags" with value "Automobiles" at index "1"
6363

6464
Scenario: Remove single multivalue by index
65-
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_set(a.tags, 0, NULL) WHERE a.tags = 'Planes'" command
65+
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_replace_at(a.tags, 0, NULL) WHERE a.tags = 'Planes'" command
6666
And I save the session
6767
Then the command should not fail
6868
And I should see the following:
@@ -85,7 +85,7 @@ Feature: Execute a a raw UPDATE query in JCR_SQL2
8585
And the node at "/cms/articles/article1" should have the property "tags" with value "Kite" at index "3"
8686

8787
Scenario: Replace a multivalue property by index
88-
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_set(a.tags, 1, 'Kite'), a.tags = array_set(a.tags, 2, 'foobar') WHERE a.tags = 'Planes'" command
88+
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_replace_at(a.tags, 1, 'Kite'), a.tags = array_replace_at(a.tags, 2, 'foobar') WHERE a.tags = 'Planes'" command
8989
And I save the session
9090
Then the command should not fail
9191
And I should see the following:
@@ -97,23 +97,23 @@ Feature: Execute a a raw UPDATE query in JCR_SQL2
9797
And the node at "/cms/articles/article1" should have the property "tags" with value "foobar" at index "2"
9898

9999
Scenario: Replace a multivalue property by invalid index
100-
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_set(a.tags, 10, 'Kite') WHERE a.tags = 'Planes'" command
100+
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_replace_at(a.tags, 10, 'Kite') WHERE a.tags = 'Planes'" command
101101
Then the command should fail
102102
And I should see the following:
103103
"""
104104
Multivalue index "10" does not exist
105105
"""
106106

107107
Scenario: Attempt to update a numerically named property (must use a selector)
108-
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_set(a.tags, a.10, 'Kite') WHERE a.tags = 'Planes'" command
108+
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_replace_at(a.tags, a.10, 'Kite') WHERE a.tags = 'Planes'" command
109109
Then the command should fail
110110
And I should see the following:
111111
"""
112112
[PHPCR\PathNotFoundException] Property 10
113113
"""
114114

115115
Scenario: Replace a multivalue property by invalid index with array (invalid)
116-
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_set(a.tags, 0, array('Kite')) WHERE a.tags = 'Planes'" command
116+
Given I execute the "UPDATE [nt:unstructured] AS a SET a.tags = array_replace_at(a.tags, 0, array('Kite')) WHERE a.tags = 'Planes'" command
117117
Then the command should fail
118118
And I should see the following:
119119
"""

src/PHPCR/Shell/Query/UpdateProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct()
5353
array_shift($values);
5454
return $values;
5555
},
56-
'array_set' => function ($operand, $current, $index, $value) {
56+
'array_replace_at' => function ($operand, $current, $index, $value) {
5757
if (!isset($current[$index])) {
5858
throw new \InvalidArgumentException(sprintf(
5959
'Multivalue index "%s" does not exist',

0 commit comments

Comments
 (0)