Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: baopham/laravel-dynamodb
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6.1.1
Choose a base ref
...
head repository: baopham/laravel-dynamodb
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Aug 6, 2020

  1. Update README.md

    Fix query index
    alfredkoncsag authored Aug 6, 2020
    Copy the full SHA
    387a5e9 View commit details

Commits on Sep 30, 2020

  1. Merge pull request #225 from alfredkoncsag/patch-1

    Update README.md
    JackPriceBurns authored Sep 30, 2020
    Copy the full SHA
    ae85c92 View commit details
  2. Copy the full SHA
    587ede8 View commit details
  3. Merge pull request #230 from baopham/hotfix/travis-fix

    Fix issues with travis ci
    JackPriceBurns authored Sep 30, 2020
    Copy the full SHA
    2c7cba9 View commit details

Commits on Jan 8, 2021

  1. Copy the full SHA
    3833ac8 View commit details

Commits on Feb 15, 2021

  1. Allow connection name to be gathered dynamically

    Jaysen Nuttall committed Feb 15, 2021
    Copy the full SHA
    8827e04 View commit details

Commits on Feb 18, 2021

  1. Merge pull request #236 from xengulai/getClientDynamicConnectionName

    Allow connection name to be gathered dynamically
    JackPriceBurns authored Feb 18, 2021
    Copy the full SHA
    5f72c16 View commit details
  2. Merge pull request #234 from stancl/patch-1

    Improve installation instructions
    JackPriceBurns authored Feb 18, 2021
    Copy the full SHA
    fe56587 View commit details

Commits on Feb 10, 2022

  1. Update to Laravel 9

    Update require to Laravel 9
    andreagroferreira authored Feb 10, 2022
    Copy the full SHA
    aa2289c View commit details
  2. Merge pull request #251 from andreagroferreira/patch-1

    Update to Laravel 9
    JackPriceBurns authored Feb 10, 2022
    Copy the full SHA
    9638116 View commit details

Commits on Feb 26, 2023

  1. Allow KeyConditionExpression when model has composite key and partiti…

    …on key only is passed in where (#254)
    
    * Allow KeyConditionExpression when model has composite key and partition key only is passed in where
    
    * fix: check if all conditions columns are present in model key names
    
    * fix: array_search can return 0 so we can't use only ! but we have to check if the result is === false
    
    * aws_iam_role debug taken from env
    
    * excluded .idea folder from git
    
    * changed composer info
    
    * fix check on wrong place
    
    * use APP_DEBUG if DYNAMO_DEBUG is not set
    
    * fixed check on condition
    
    * only DYNAMODB_DEBUG
    
    ---------
    
    Co-authored-by: Claudio La Barbera <claudio.labarbera@myfamilyplace.com>
    thebatclaudio and Claudio La Barbera authored Feb 26, 2023
    Copy the full SHA
    d406957 View commit details

Commits on Apr 18, 2023

  1. Bump dependencies for Laravel 10

    laravel-shift authored and nelson6e65 committed Apr 18, 2023
    Copy the full SHA
    bd3298b View commit details
  2. Copy the full SHA
    91aca79 View commit details
  3. Merge pull request #270 from baopham/php-81

    feat: allow Laravel 10 and PHP 8.2 (basic)
    nelson6e65 authored Apr 18, 2023
    Copy the full SHA
    4e35d27 View commit details

Commits on Jul 9, 2023

  1. fix key for dynamodb_local

    crhg committed Jul 9, 2023
    Copy the full SHA
    9a95f91 View commit details

Commits on Jul 10, 2023

  1. fix key in DynamoDbTestCase.php

    Manabu Matsui committed Jul 10, 2023
    Copy the full SHA
    30201f2 View commit details
  2. database file must be named myaccesskeyid_region.db

    Manabu Matsui committed Jul 10, 2023
    Copy the full SHA
    5d6eabb View commit details
  3. Merge pull request #272 from crhg/fix_dynamodb_local_key

    feat(docker): add compatibility with dynamodb-local 2.0
    nelson6e65 authored Jul 10, 2023
    Copy the full SHA
    43bcfc6 View commit details

Commits on Apr 2, 2024

  1. fix(test): replace setMethods (deprecated) with onlyMethods and add a…

    … new DynamoDbClientMock class to declare the needed methods (otherwise onlyMethods would not work)
    Claudio La Barbera committed Apr 2, 2024
    Copy the full SHA
    f55d66c View commit details
  2. fix(test): automatic update phpunit.xml

    Claudio La Barbera committed Apr 2, 2024
    Copy the full SHA
    00e3c3c View commit details
  3. fix(style): opening brace should be on a new line

    Claudio La Barbera committed Apr 2, 2024
    Copy the full SHA
    4bb8270 View commit details

Commits on Apr 3, 2024

  1. Merge pull request #281 from thebatclaudio/fix/fix-failing-tests

    Fix failing tests and update phpunit.xml
    nelson6e65 authored Apr 3, 2024
    Copy the full SHA
    0188300 View commit details
  2. Laravel 11 compatibility (#282)

    Add Laravel 11 compatibilty:
    
    illuminate/support^11.0
    illuminate/database^11.0
    Claudio La Barbera authored Apr 3, 2024
    Copy the full SHA
    ee527b0 View commit details

Commits on Apr 14, 2024

  1. fix: illuminate/database version constraint

    nelson6e65 committed Apr 14, 2024
    Copy the full SHA
    1ed8090 View commit details
Showing with 123 additions and 62 deletions.
  1. +3 −0 .gitignore
  2. +1 −1 .travis.yml
  3. +3 −3 README.md
  4. +42 −38 composer.json
  5. +3 −3 config/dynamodb.php
  6. +10 −10 phpunit.xml
  7. +10 −2 src/ConditionAnalyzer/Analyzer.php
  8. +1 −1 src/DynamoDbModel.php
  9. +6 −0 src/RawDynamoDbQuery.php
  10. +3 −2 tests/DynamoDb/DynamoDbManagerTest.php
  11. +2 −2 tests/DynamoDbTestCase.php
  12. +39 −0 tests/Mocks/DynamoDbClientMock.php
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -4,5 +4,8 @@ dynamodb_local_test.db
/nbproject
*.log
.php_cs.cache
.idea

.phpunit.result.cache

/node_modules
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ before_script:
- java -Djava.library.path=./DynamoDBLocal_lib -jar dynamodb_local/DynamoDBLocal.jar --port 3000 &
- sleep 2
- composer self-update
- composer install
- COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --prefer-dist --no-interaction

script: ./vendor/bin/phpunit

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ Install
composer require baopham/dynamodb
```

* Install service provider:
* Install service provider (< Laravel 5.5):

```php
// config/app.php
@@ -64,7 +64,7 @@ Install
* Run

```php
php artisan vendor:publish
php artisan vendor:publish --provider 'BaoPham\DynamoDb\DynamoDbServiceProvider'
```

* Update DynamoDb config in [config/dynamodb.php](config/dynamodb.php)
@@ -504,7 +504,7 @@ DynamoDb::table('articles')
->scan(); // supports any DynamoDbClient methods (e.g. batchWriteItem, batchGetItem, etc.)
DynamoDb::table('articles')
->setIndex('author_name')
->setIndexName('author_name')
->setKeyConditionExpression('#name = :name')
->setProjectionExpression('id, author_name')
// Can set the attribute mapping one by one instead
80 changes: 42 additions & 38 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
{
"name": "baopham/dynamodb",
"description": "Eloquent syntax for DynamoDB",
"keywords": ["laravel", "dynamodb", "aws"],
"require": {
"aws/aws-sdk-php": "^3.0.0",
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0 || ^8.0",
"illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0 || ^8.0"
},
"license": "MIT",
"authors": [
{
"name": "Bao Pham",
"email": "gbaopham@gmail.com"
}
],
"autoload": {
"psr-4": {
"BaoPham\\DynamoDb\\": "src/"
}
},
"require-dev": {
"orchestra/testbench": "~3.0 || ~5.0"
},
"scripts": {
"test": "phpunit",
"dynamodb_local": "java -Djava.library.path=./DynamoDBLocal_lib -jar dynamodb_local/DynamoDBLocal.jar --port 3000"
},
"autoload-dev": {
"psr-4": {
"BaoPham\\DynamoDb\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"BaoPham\\DynamoDb\\DynamoDbServiceProvider"
]
}
"name": "baopham/dynamodb",
"description": "Eloquent syntax for DynamoDB",
"keywords": [
"laravel",
"dynamodb",
"aws"
],
"require": {
"aws/aws-sdk-php": "^3.0.0",
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
"illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0"
},
"license": "MIT",
"authors": [
{
"name": "Bao Pham",
"email": "gbaopham@gmail.com"
}
],
"autoload": {
"psr-4": {
"BaoPham\\DynamoDb\\": "src/"
}
},
"require-dev": {
"orchestra/testbench": "~3.0 || ~5.0|^8.0"
},
"scripts": {
"test": "phpunit",
"dynamodb_local": "java -Djava.library.path=./DynamoDBLocal_lib -jar dynamodb_local/DynamoDBLocal.jar --port 3000"
},
"autoload-dev": {
"psr-4": {
"BaoPham\\DynamoDb\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"BaoPham\\DynamoDb\\DynamoDbServiceProvider"
]
}
}
}
6 changes: 3 additions & 3 deletions config/dynamodb.php
Original file line number Diff line number Diff line change
@@ -39,11 +39,11 @@
],
'aws_iam_role' => [
'region' => env('DYNAMODB_REGION'),
'debug' => true,
'debug' => env('DYNAMODB_DEBUG'),
],
'local' => [
'credentials' => [
'key' => 'dynamodb_local',
'key' => 'dynamodblocal',
'secret' => 'secret',
],
'region' => 'stub',
@@ -53,7 +53,7 @@
],
'test' => [
'credentials' => [
'key' => 'dynamodb_local',
'key' => 'dynamodblocal',
'secret' => 'secret',
],
'region' => 'test',
20 changes: 10 additions & 10 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<source>
<include>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</include>
</source>
</phpunit>
12 changes: 10 additions & 2 deletions src/ConditionAnalyzer/Analyzer.php
Original file line number Diff line number Diff line change
@@ -71,10 +71,18 @@ public function isExactSearch()
return false;
}

if (count($this->conditions) !== count($this->model->getKeyNames())) {
return false;
}

foreach ($this->conditions as $condition) {
if (Arr::get($condition, 'type') !== ComparisonOperator::EQ) {
return false;
}

if (array_search(Arr::get($condition, 'column'), $this->model->getKeyNames()) === false) {
return false;
}
}

return true;
@@ -202,8 +210,8 @@ private function hasValidQueryOperator($hash, $range = null)
$hashConditionType = $this->getCondition($hash)['type'] ?? null;
$validQueryOp = ComparisonOperator::isValidQueryDynamoDbOperator($hashConditionType);

if ($validQueryOp && $range) {
$rangeConditionType = $this->getCondition($range)['type'] ?? null;
if ($validQueryOp && $range && $this->getCondition($range) !== null) {
$rangeConditionType = $this->getCondition($range)['type'];
$validQueryOp = ComparisonOperator::isValidQueryDynamoDbOperator(
$rangeConditionType,
true
2 changes: 1 addition & 1 deletion src/DynamoDbModel.php
Original file line number Diff line number Diff line change
@@ -352,7 +352,7 @@ public function setId($id)
*/
public function getClient()
{
return static::$dynamoDb->getClient($this->connection);
return static::$dynamoDb->getClient($this->getConnectionName());
}

/**
6 changes: 6 additions & 0 deletions src/RawDynamoDbQuery.php
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ public function finalize()
* The return value will be casted to boolean if non-boolean was returned.
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->internal()[$offset]);
@@ -70,6 +71,7 @@ public function offsetExists($offset)
* @return mixed Can return all value types.
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->internal()[$offset];
@@ -87,6 +89,7 @@ public function offsetGet($offset)
* @return void
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->internal()[$offset] = $value;
@@ -101,6 +104,7 @@ public function offsetSet($offset, $value)
* @return void
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->internal()[$offset]);
@@ -113,6 +117,7 @@ public function offsetUnset($offset)
* <b>Traversable</b>
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new \ArrayObject($this->internal());
@@ -127,6 +132,7 @@ public function getIterator()
* The return value is cast to an integer.
* @since 5.1.0
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->internal());
5 changes: 3 additions & 2 deletions tests/DynamoDb/DynamoDbManagerTest.php
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
use BaoPham\DynamoDb\DynamoDbClientInterface;
use BaoPham\DynamoDb\Tests\DynamoDbTestCase;
use BaoPham\DynamoDb\DynamoDb\DynamoDbManager;
use BaoPham\DynamoDb\Tests\Mocks\DynamoDbClientMock;

class DynamoDbManagerTest extends DynamoDbTestCase
{
@@ -25,9 +26,9 @@ public function setUp(): void
parent::setUp();

$this->mockedClient = $this
->getMockBuilder(DynamoDbClient::class)
->getMockBuilder(DynamoDbClientMock::class)
->disableOriginalConstructor()
->setMethods(['putItem', 'updateItem', 'deleteItem', 'scan', 'query', 'batchWriteItem'])
->onlyMethods(['putItem', 'updateItem', 'deleteItem', 'scan', 'query', 'batchWriteItem'])
->getMock();

$service = $this->getMockBuilder(DynamoDbClientInterface::class)->getMock();
4 changes: 2 additions & 2 deletions tests/DynamoDbTestCase.php
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ protected function getEnvironmentSetUp($app)
{
$app['config']->set('dynamodb.connections.test', [
'credentials' => [
'key' => 'dynamodb_local',
'key' => 'dynamodblocal',
'secret' => 'secret',
],
'region' => 'test',
@@ -44,6 +44,6 @@ protected function getEnvironmentSetUp($app)

protected function setUpDatabase()
{
copy(dirname(__FILE__) . '/../dynamodb_local_init.db', dirname(__FILE__) . '/../dynamodb_local_test.db');
copy(dirname(__FILE__) . '/../dynamodb_local_init.db', dirname(__FILE__) . '/../dynamodblocal_test.db');
}
}
39 changes: 39 additions & 0 deletions tests/Mocks/DynamoDbClientMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace BaoPham\DynamoDb\Tests\Mocks;

use Aws\DynamoDb\DynamoDbClient;
use Aws\Result;

class DynamoDbClientMock extends DynamoDbClient
{
public function putItem(array $args = []): Result
{
return parent::putItem($args);
}

public function updateItem(array $args = []): Result
{
return parent::updateItem($args);
}

public function deleteItem(array $args = []): Result
{
return parent::deleteItem($args);
}

public function scan(array $args = []): Result
{
return parent::scan($args);
}

public function query(array $args = []): Result
{
return parent::query($args);
}

public function batchWriteItem(array $args = []): Result
{
return parent::batchWriteItem($args);
}
}