@@ -91,7 +91,7 @@ protected static function getInstance()
9191        if  (is_null (static ::$ instance
9292            static ::$ instancenew  static ;
9393        }
94-          
94+ 
9595        return  static ::$ instance
9696    }
9797
@@ -272,6 +272,12 @@ public function get($columns = [])
272272
273273    protected  function  getAll ($ columns$ limit1 )
274274    {
275+         if  ($ conditionValue$ this conditionsContainKey ()) {
276+             $ item$ this find ($ conditionValue$ columns
277+ 
278+             return  new  Collection ([$ item
279+         }
280+ 
275281        $ query
276282            'TableName '  => $ this getTable (),
277283        ];
@@ -289,7 +295,7 @@ protected function getAll($columns = [], $limit = -1)
289295        // If the $where is not empty, we run getIterator. 
290296        if  (!empty ($ this where )) {
291297
292-             // Primary key or index  key condition exists, then use Query instead of Scan. 
298+             // Index  key condition exists, then use Query instead of Scan. 
293299            // However, Query only supports a few conditions. 
294300            if  ($ key$ this conditionsContainIndexKey ()) {
295301                $ conditionarray_get ($ this where , "$ key.ComparisonOperator " );
@@ -317,6 +323,41 @@ protected function getAll($columns = [], $limit = -1)
317323        return  new  Collection ($ results
318324    }
319325
326+     /** 
327+      * Check if conditions "where" contain primary key or composite key. 
328+      * For composite key, it will return false if the conditions don't have all composite key. 
329+      * 
330+      * @return array|bool the condition value 
331+      */ 
332+     protected  function  conditionsContainKey ()
333+     {
334+         if  (empty ($ this where )) {
335+             return  false ;
336+         }
337+ 
338+         $ conditionKeysarray_keys ($ this where );
339+ 
340+         $ keys$ this hasCompositeKey () ? $ this compositeKey  : [$ this getKeyName ()];
341+ 
342+         $ conditionsContainKeycount (array_intersect ($ conditionKeys$ keyscount ($ keys
343+ 
344+         if  (!$ conditionsContainKey
345+             return  false ;
346+         }
347+ 
348+         $ conditionValue
349+ 
350+         foreach  ($ keysas  $ key
351+             $ condition$ this where [$ key
352+ 
353+             $ value$ this unmarshalItem (array_get ($ condition'AttributeValueList ' ))[0 ];
354+ 
355+             $ conditionValue$ key$ value
356+         }
357+ 
358+         return  $ conditionValue
359+     }
360+ 
320361    protected  function  conditionsContainIndexKey ()
321362    {
322363        if  (empty ($ this where )) {
0 commit comments