@@ -548,35 +548,36 @@ public static function pipe(
548
548
);
549
549
}
550
550
551
- // Test for alternative key syntax
552
- $ alternateKey = $ lexer ->with (function (Lexer $ lexer ) {
551
+ // Test for non-canonical long form with specified key property name
552
+ $ longFormKey = $ lexer ->with (function (Lexer $ lexer ) {
553
553
return $ lexer ->identifier ();
554
554
});
555
555
556
- if ($ alternateKey ) {
557
- if ($ lexer ->maybeChar ('= ' )) {
558
- // Test for referenced value syntax
559
- if ($ lexer ->maybeChar ('@ ' )) {
560
- $ referencedKey = $ lexer ->identifier ();
561
- $ referencedValue = $ transaction ->getParameterAlias ($ referencedKey );
562
- $ lexer = new Lexer ($ referencedValue );
563
- }
556
+ if ($ longFormKey && $ lexer ->maybeChar ('= ' )) {
557
+ // Test for referenced value syntax
558
+ if ($ lexer ->maybeChar ('@ ' )) {
559
+ $ referencedKey = $ lexer ->identifier ();
560
+ $ referencedValue = $ transaction ->getParameterAlias ($ referencedKey );
561
+ $ lexer = new Lexer ($ referencedValue );
562
+ }
564
563
565
- $ keyProperty = $ entitySet ->getType ()->getProperty ($ alternateKey );
564
+ $ requestedKeyProperty = $ entitySet ->getType ()->getProperty ($ longFormKey );
566
565
567
- if ($ keyProperty instanceof DeclaredProperty && !$ keyProperty ->isAlternativeKey ()) {
568
- throw new BadRequestException (
569
- 'property_not_alternative_key ' ,
570
- sprintf (
571
- 'The requested property (%s) is not configured as an alternative key ' ,
572
- $ alternateKey
573
- )
574
- );
575
- }
576
- } else {
577
- // Captured value was not an alternative key, reset the lexer
578
- $ lexer = new Lexer ($ id );
566
+ if ($ requestedKeyProperty instanceof DeclaredProperty
567
+ && !($ requestedKeyProperty ->isAlternativeKey () || $ keyProperty ->getName () === $ requestedKeyProperty ->getName ())) {
568
+ throw new BadRequestException (
569
+ 'property_not_alternative_key ' ,
570
+ sprintf (
571
+ 'The requested property (%s) is not configured as key or alternative key ' ,
572
+ $ longFormKey
573
+ )
574
+ );
579
575
}
576
+ $ keyProperty = $ requestedKeyProperty ;
577
+
578
+ } else {
579
+ // Captured value was not an alternative key, reset the lexer
580
+ $ lexer = new Lexer ($ id );
580
581
}
581
582
582
583
if (null === $ keyProperty ) {
@@ -1261,4 +1262,4 @@ public function toArray(ComplexValue $complexValue): array
1261
1262
1262
1263
return $ result ;
1263
1264
}
1264
- }
1265
+ }
0 commit comments