How to Use hypen as key name in dynamo db mapper

0 votes

I am getting Invalid KeyConditionExpression: Syntax error; token: "-", near:foo-bar when the key name has hypen. I have tried using the with expression attribute names and attribute values but still i am getting the same error. How can i solve this issue?

Invalid KeyConditionExpression: Syntax error; token: "-", near: Map<String,String> 
eak = new HashMap<>(); eak.put("#k","foo-bar"); 
Map<String, AttributeValue> eav = new HashMap<>(); 
eav.put(":v", new AttributeValue().withS("val")); 
DynamoDBQueryExpression<J> queryExpression = new DynamoDBQueryExpression<J>()
             .withKeyConditionExpression("#k = :v")
.withExpressionAttributeNames(eak) 
             .withExpressionAttributeValues(eav) 
             .withScanIndexForward(true);
Aug 22, 2018 in AWS by bug_seeker
• 15,350 points
133 views

1 answer to this question.

0 votes

It seems you cannot have a column containing a hyphen, foo-bar, while using it the KeyConditionExpression.

In your example, the .withKeyConditionExpression("#k = :v")

• is expended to .f("foo-bar = val"),

• which is similar to .f("foo - bar = val") (note the spaces around -).

The - is no longer interpreted as a character in a column name, but as an operand.

For obvious reasons, this will throw an error, because the - is not in an allowed position.

answered Aug 22, 2018 by Priyaj
• 56,540 points

Related Questions In AWS

0 votes
0 answers

I want to get file name from key in S3 bucket wanted to read single file from list of file present in bucket

1 <class 'boto.s3.key.Key'> <Key: numbers-email, staging/Procured_Numbers_Status/procured_numbers_status_2019-05-15:06:09:04.csv> I ...READ MORE

May 15 in AWS by anonymous
68 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
152 views
0 votes
1 answer
+1 vote
1 answer

Can we use AWS Public DNS as Domian name to enable https on our instance

I don't believe you can get a ...READ MORE

answered Aug 23, 2018 in AWS by Priyaj
• 56,540 points
43 views
+1 vote
1 answer