Skip to content

Commit

Permalink
Fix Query fails with more than 10 attributes in a query filter condit…
Browse files Browse the repository at this point in the history
…ion. (pynamodb#751)
  • Loading branch information
Eric Muller committed Feb 10, 2020
1 parent 5426ed9 commit 3dbb404
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pynamodb/connection/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import logging
import random
import re
import sys
import time
import uuid
Expand Down Expand Up @@ -1240,11 +1241,12 @@ def query(self,
# FilterExpression does not allow key attributes. Check for hash and range key name placeholders
hash_key_placeholder = name_placeholders.get(hash_keyname)
range_key_placeholder = range_keyname and name_placeholders.get(range_keyname)
if (
hash_key_placeholder in filter_expression or
(range_key_placeholder and range_key_placeholder in filter_expression)
):
raise ValueError("'filter_condition' cannot contain key attributes")
if re.search(hash_key_placeholder + r"\D", filter_expression):
raise ValueError("'filter_condition' cannot contain hash key. {} found in {}"
.format(hash_key_placeholder, filter_expression))
if range_key_placeholder and re.search(range_key_placeholder + r"\D", filter_expression):
raise ValueError("'filter_condition' cannot contain range key. {} found in {}"
.format(range_key_placeholder, filter_expression))
operation_kwargs[FILTER_EXPRESSION] = filter_expression
if attributes_to_get:
projection_expression = create_projection_expression(attributes_to_get, name_placeholders)
Expand Down

0 comments on commit 3dbb404

Please sign in to comment.