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")
Aug 22, 2018 in AWS by bug_seeker
• 15,550 points

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
• 58,120 points

Related Questions In AWS

0 votes
1 answer
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, 2019 in AWS by anonymous
0 votes
1 answer

How to create MariaDB DB instance in AWS?

Hi@akhtar, To create a MariaDB DB instance with ...READ MORE

answered Jul 26, 2020 in AWS by MD
• 95,180 points
+15 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,450 points
+2 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
• 58,120 points
+2 votes
1 answer