doctrine / KeyValueStore

Abstraction for Key-Value to Plain Old PHP Object mapping
http://www.doctrine-project.org
MIT License
201 stars 59 forks source link

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

Open psociety opened 4 years ago

psociety commented 4 years ago

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.

KorvinSzanto commented 3 years ago

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