DynamoDB - array_combine(): Both parameters should have an equal number of elements #39

Open
opened 2026-01-23 11:34:58 +01:00 by admin · 1 comment
Owner

Originally created by @psociety on GitHub (Jun 22, 2020).

Version: v0.4.0
Error:

array_combine(): Both parameters should have an equal number of elements

/app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php:116
/app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php:136
/app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/UnitOfWork.php:255
/app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/UnitOfWork.php:280
/app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/EntityManager.php:115

Table format:

$params = [
            'TableName' => "user",
            'KeySchema' => [
                [
                    'AttributeName' => 'id',
                    'KeyType' => 'HASH'  // partition key
                ],
                [
                    'AttributeName' => 'createdAt',
                    'KeyType' => 'RANGE' // sort key
                ]
            ],
            'AttributeDefinitions' => [
                [
                    'AttributeName' => 'id',
                    'AttributeType' => 'S' // S (string), N (number), B (binary)
                ],
                [
                    'AttributeName' => 'createdAt',
                    'AttributeType' => 'N'
                ],
                [
                    'AttributeName' => 'userIdGroup',
                    'AttributeType' => 'S'
                ],
            ],
            'GlobalSecondaryIndexes' => [
                [
                    'IndexName' => 'type-grouped',
                    'KeySchema' => [
                        [
                            'AttributeName' => 'userIdGroup',
                            'KeyType' => 'HASH'  // partition key
                        ],
                        [
                            'AttributeName' => 'createdAt',
                            'KeyType' => 'RANGE' // sort key
                        ]
                    ],
                    'Projection' => [
                       // 'NonKeyAttributes' => ['userIdGroup'],
                        'ProjectionType' => 'ALL',
                    ],
                    'ProvisionedThroughput' => [
                        'ReadCapacityUnits' => 10,
                        'WriteCapacityUnits' => 10
                    ],
                ],
            ],
            'ProvisionedThroughput' => [
                'ReadCapacityUnits' => 10,
                'WriteCapacityUnits' => 10
            ]
        ];
        $this->dynamoDb->createTable($params);

Explodes when doing a find by primary key.

Originally created by @psociety on GitHub (Jun 22, 2020). **Version:** v0.4.0 **Error:** > array_combine(): Both parameters should have an equal number of elements > > /app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php:116 > /app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php:136 > /app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/UnitOfWork.php:255 > /app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/UnitOfWork.php:280 > /app/vendor/doctrine/key-value-store/lib/Doctrine/KeyValueStore/EntityManager.php:115 > **Table format:** ```php $params = [ 'TableName' => "user", 'KeySchema' => [ [ 'AttributeName' => 'id', 'KeyType' => 'HASH' // partition key ], [ 'AttributeName' => 'createdAt', 'KeyType' => 'RANGE' // sort key ] ], 'AttributeDefinitions' => [ [ 'AttributeName' => 'id', 'AttributeType' => 'S' // S (string), N (number), B (binary) ], [ 'AttributeName' => 'createdAt', 'AttributeType' => 'N' ], [ 'AttributeName' => 'userIdGroup', 'AttributeType' => 'S' ], ], 'GlobalSecondaryIndexes' => [ [ 'IndexName' => 'type-grouped', 'KeySchema' => [ [ 'AttributeName' => 'userIdGroup', 'KeyType' => 'HASH' // partition key ], [ 'AttributeName' => 'createdAt', 'KeyType' => 'RANGE' // sort key ] ], 'Projection' => [ // 'NonKeyAttributes' => ['userIdGroup'], 'ProjectionType' => 'ALL', ], 'ProvisionedThroughput' => [ 'ReadCapacityUnits' => 10, 'WriteCapacityUnits' => 10 ], ], ], 'ProvisionedThroughput' => [ 'ReadCapacityUnits' => 10, 'WriteCapacityUnits' => 10 ] ]; $this->dynamoDb->createTable($params); ``` Explodes when doing a find by primary key.
Author
Owner

@KorvinSzanto commented on GitHub (Dec 18, 2020):

This seems to happen for me only if my table has a sort key enabled

@KorvinSzanto commented on GitHub (Dec 18, 2020): This seems to happen for me only if my table has a sort key enabled
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/KeyValueStore#39