derjust / spring-data-dynamodb

This module deals with enhanced support for a data access layer built on AWS DynamoDB.
https://derjust.github.io/spring-data-dynamodb/
Apache License 2.0
403 stars 141 forks source link

Projection with findById (getItem and not query) #227

Open Ovadia-B opened 5 years ago

Ovadia-B commented 5 years ago

Expected Behavior

Only the required attributes will be returned when using the @Query annotation and all the rest will be nulls, ie:

        HashMap<String, AttributeValue> key = new HashMap<>();
        key.put("id", new AttributeValue(hitId));
        GetItemRequest request = new GetItemRequest()
                .withKey(key)
                .withTableName("tablename")
                .withProjectionExpression("username");
        GetItemResult item = db.getItem(request);

Actual Behavior

All the attributes are returned

Steps to Reproduce the Problem

  1. create findById (partition key) method
  2. check the returned object

Specifications

Spring Data DynamoDB Version: 5.0.4 (2.0) Spring Data Version: 2.0.9.RELEASE AWS SDK Version: 1.11.390 Java Version: 1.8.0_20 - Java HotSpot(TM) 64-Bit Server VM 25.20-b23 Platform Details: Windows 8.1 6.3

derjust commented 5 years ago

Triage: As of right now, @Query is only respected for Scans but not Queries