Why won't boto3's FilterExpression accept more than 1 expression?
I am really baffled as to what I am doing wrong. It seems like the request I am making to the boto3 dynamodb client is perfect from what I can tell, but I am still not getting any results when I run the query. I suspect it's something to do with the FilterExpression, but I can't fathom it.
I am using a zappa/flask combo to build a web app, and I'm using dynamodb as the database. My AWS credentials and permissions are fine--I know that because I can run simpler queries just fine. Beyond that, the wider context of the application isn't relevant to my question.
I am running the following commands within the context of an object:
args = {... see below ...}
self.db = boto3.client('dynamodb')
self.db.query(**args)
Below is the args argument that I send to the client:
{"TableName": "clients",
"IndexName": "client_id",
"FilterExpression": "#filattr0 < :filattrval0 AND #filattr1 = :filattrval1",
"KeyConditionExpression": "#keyindexattr0 = :keyindexvalue0",
"ExpressionAttributeNames": {
"#filattr0": "time",
"#filattr1": "status",
"#keyindexattr0": "client_id"
},
"ExpressionAttributeValues": {
":filattrval0": {"N": "1542696080"},
":filattrval1": {"S": "pending"},
":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
"Limit": 100,
"ConsistentRead": false,
"Select": "ALL_ATTRIBUTES"}
The response I get back from this query is the following:
{'Items': ,
'Count': 0,
'ScannedCount': 8,
'ResponseMetadata': {'RequestId': '*blahblahblah*',
'HTTPStatusCode': 200,
'HTTPHeaders': {
'server': 'Server',
'date': 'Tue, 20 Nov 2018 06:41:20 GMT',
'content-type': 'application/x-amz-json-1.0',
'content-length': '39',
'connection': 'keep-alive',
'x-amzn-requestid': '*blahblahblah*',
'x-amz-crc32': '*numbers*'},
'RetryAttempts': 0
}}
Now, I am looking at the dynamodb table through my AWS Console, and it is showing me the following object in the appropriate table. In fact, when I construct this query in the table view of the dynamodb console on the AWS Website, it returns the following object, so I know the parameters are acceptable to AWS:
# Taken from the JSON view of the item in the database
# I removed the UUIDs just in case...
{
"client_id": "00000000-0000-0000-000000000000",
"modify_date": "1542637150",
"schedule_id": "00000000-0000-0000-000000000000",
"software_version": "0.1",
"status": "pending",
"template_id": "00000000-0000-0000-000000000000",
"time": "1542646800",
"timezone": "PDT"
}
The weirdest thing is that when I run the query using the following args variable:
{'TableName': 'hmcmSchedule',
'IndexName': 'client_id',
'FilterExpression': '#filattr0 = :filattrval0',
'KeyConditionExpression': '#keyindexattr0 = :keyindexvalue0',
'ExpressionAttributeNames': {
'#filattr0': 'status',
'#keyindexattr0': 'client_id'
},
'ExpressionAttributeValues': {
':filattrval0': {'S': 'pending'},
':keyindexvalue0': {'S': '00000000-0000-0000-000000000000'}
},
'Limit': 100,
'ConsistentRead': False,
'Select': 'ALL_ATTRIBUTES'}
I get the following response from the database:
# UUIDs have once again been removed, just in case...
{'Items': [{
'modify_date': {'S': '1542637150'},
'template_id': {'S': '00000000-0000-0000-000000000000'},
'software_version': {'S': '0.1'},
'client_id': {'S': '00000000-0000-0000-000000000000'},
'status': {'S': 'pending'},
'timezone': {'S': 'PDT'},
'time': {'S': '1542646800'},
'schedule_id': {'S': '00000000-0000-0000-000000000000'}
}],
'Count': 1,
'ScannedCount': 8,
'ResponseMetadata': {
'RequestId': '*blahblahblah*',
'HTTPStatusCode': 200,
'HTTPHeaders': {
'server': 'Server',
'date': 'Tue, 20 Nov 2018 07:55:59 GMT',
'content-type': 'application/x-amz-json-1.0',
'content-length': '348',
'connection': 'keep-alive',
'x-amzn-requestid': '*blahblahblah*',
'x-amz-crc32': '1922642857'
},
'RetryAttempts': 0}}
What is it about my FilterExpression that is keeping this from working? I've been examining it for hours, and can't see the forest for the trees. I read the documentation extensively, and I think i've covered everything.
Any help or insight anybody could offer would b greatly appreciated...
amazon-web-services amazon-dynamodb boto3 dynamodb-queries
add a comment |
I am really baffled as to what I am doing wrong. It seems like the request I am making to the boto3 dynamodb client is perfect from what I can tell, but I am still not getting any results when I run the query. I suspect it's something to do with the FilterExpression, but I can't fathom it.
I am using a zappa/flask combo to build a web app, and I'm using dynamodb as the database. My AWS credentials and permissions are fine--I know that because I can run simpler queries just fine. Beyond that, the wider context of the application isn't relevant to my question.
I am running the following commands within the context of an object:
args = {... see below ...}
self.db = boto3.client('dynamodb')
self.db.query(**args)
Below is the args argument that I send to the client:
{"TableName": "clients",
"IndexName": "client_id",
"FilterExpression": "#filattr0 < :filattrval0 AND #filattr1 = :filattrval1",
"KeyConditionExpression": "#keyindexattr0 = :keyindexvalue0",
"ExpressionAttributeNames": {
"#filattr0": "time",
"#filattr1": "status",
"#keyindexattr0": "client_id"
},
"ExpressionAttributeValues": {
":filattrval0": {"N": "1542696080"},
":filattrval1": {"S": "pending"},
":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
"Limit": 100,
"ConsistentRead": false,
"Select": "ALL_ATTRIBUTES"}
The response I get back from this query is the following:
{'Items': ,
'Count': 0,
'ScannedCount': 8,
'ResponseMetadata': {'RequestId': '*blahblahblah*',
'HTTPStatusCode': 200,
'HTTPHeaders': {
'server': 'Server',
'date': 'Tue, 20 Nov 2018 06:41:20 GMT',
'content-type': 'application/x-amz-json-1.0',
'content-length': '39',
'connection': 'keep-alive',
'x-amzn-requestid': '*blahblahblah*',
'x-amz-crc32': '*numbers*'},
'RetryAttempts': 0
}}
Now, I am looking at the dynamodb table through my AWS Console, and it is showing me the following object in the appropriate table. In fact, when I construct this query in the table view of the dynamodb console on the AWS Website, it returns the following object, so I know the parameters are acceptable to AWS:
# Taken from the JSON view of the item in the database
# I removed the UUIDs just in case...
{
"client_id": "00000000-0000-0000-000000000000",
"modify_date": "1542637150",
"schedule_id": "00000000-0000-0000-000000000000",
"software_version": "0.1",
"status": "pending",
"template_id": "00000000-0000-0000-000000000000",
"time": "1542646800",
"timezone": "PDT"
}
The weirdest thing is that when I run the query using the following args variable:
{'TableName': 'hmcmSchedule',
'IndexName': 'client_id',
'FilterExpression': '#filattr0 = :filattrval0',
'KeyConditionExpression': '#keyindexattr0 = :keyindexvalue0',
'ExpressionAttributeNames': {
'#filattr0': 'status',
'#keyindexattr0': 'client_id'
},
'ExpressionAttributeValues': {
':filattrval0': {'S': 'pending'},
':keyindexvalue0': {'S': '00000000-0000-0000-000000000000'}
},
'Limit': 100,
'ConsistentRead': False,
'Select': 'ALL_ATTRIBUTES'}
I get the following response from the database:
# UUIDs have once again been removed, just in case...
{'Items': [{
'modify_date': {'S': '1542637150'},
'template_id': {'S': '00000000-0000-0000-000000000000'},
'software_version': {'S': '0.1'},
'client_id': {'S': '00000000-0000-0000-000000000000'},
'status': {'S': 'pending'},
'timezone': {'S': 'PDT'},
'time': {'S': '1542646800'},
'schedule_id': {'S': '00000000-0000-0000-000000000000'}
}],
'Count': 1,
'ScannedCount': 8,
'ResponseMetadata': {
'RequestId': '*blahblahblah*',
'HTTPStatusCode': 200,
'HTTPHeaders': {
'server': 'Server',
'date': 'Tue, 20 Nov 2018 07:55:59 GMT',
'content-type': 'application/x-amz-json-1.0',
'content-length': '348',
'connection': 'keep-alive',
'x-amzn-requestid': '*blahblahblah*',
'x-amz-crc32': '1922642857'
},
'RetryAttempts': 0}}
What is it about my FilterExpression that is keeping this from working? I've been examining it for hours, and can't see the forest for the trees. I read the documentation extensively, and I think i've covered everything.
Any help or insight anybody could offer would b greatly appreciated...
amazon-web-services amazon-dynamodb boto3 dynamodb-queries
IMHO, the best place for database related question is dba.stackexchange.com . BTW, this is not a boto3 question.
– mootmoot
Nov 20 '18 at 10:18
According to the output of the successful query, it looks liketime
wasn't stored as a number, but as a string:'time': {'S': '1542646800'},
I might be wrong but comparing this to a number seems problematic.
– Michael - sqlbot
Nov 20 '18 at 12:56
@Michael-sqlbot, I don't think it's that time was stored as a string, as the datatype in the database is number. It is odd that it was returned as a string, but the documentation did say that dynamodb sends and receives all values as strings. So it may just be a quirk of the system.
– user3628576
Nov 20 '18 at 15:44
add a comment |
I am really baffled as to what I am doing wrong. It seems like the request I am making to the boto3 dynamodb client is perfect from what I can tell, but I am still not getting any results when I run the query. I suspect it's something to do with the FilterExpression, but I can't fathom it.
I am using a zappa/flask combo to build a web app, and I'm using dynamodb as the database. My AWS credentials and permissions are fine--I know that because I can run simpler queries just fine. Beyond that, the wider context of the application isn't relevant to my question.
I am running the following commands within the context of an object:
args = {... see below ...}
self.db = boto3.client('dynamodb')
self.db.query(**args)
Below is the args argument that I send to the client:
{"TableName": "clients",
"IndexName": "client_id",
"FilterExpression": "#filattr0 < :filattrval0 AND #filattr1 = :filattrval1",
"KeyConditionExpression": "#keyindexattr0 = :keyindexvalue0",
"ExpressionAttributeNames": {
"#filattr0": "time",
"#filattr1": "status",
"#keyindexattr0": "client_id"
},
"ExpressionAttributeValues": {
":filattrval0": {"N": "1542696080"},
":filattrval1": {"S": "pending"},
":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
"Limit": 100,
"ConsistentRead": false,
"Select": "ALL_ATTRIBUTES"}
The response I get back from this query is the following:
{'Items': ,
'Count': 0,
'ScannedCount': 8,
'ResponseMetadata': {'RequestId': '*blahblahblah*',
'HTTPStatusCode': 200,
'HTTPHeaders': {
'server': 'Server',
'date': 'Tue, 20 Nov 2018 06:41:20 GMT',
'content-type': 'application/x-amz-json-1.0',
'content-length': '39',
'connection': 'keep-alive',
'x-amzn-requestid': '*blahblahblah*',
'x-amz-crc32': '*numbers*'},
'RetryAttempts': 0
}}
Now, I am looking at the dynamodb table through my AWS Console, and it is showing me the following object in the appropriate table. In fact, when I construct this query in the table view of the dynamodb console on the AWS Website, it returns the following object, so I know the parameters are acceptable to AWS:
# Taken from the JSON view of the item in the database
# I removed the UUIDs just in case...
{
"client_id": "00000000-0000-0000-000000000000",
"modify_date": "1542637150",
"schedule_id": "00000000-0000-0000-000000000000",
"software_version": "0.1",
"status": "pending",
"template_id": "00000000-0000-0000-000000000000",
"time": "1542646800",
"timezone": "PDT"
}
The weirdest thing is that when I run the query using the following args variable:
{'TableName': 'hmcmSchedule',
'IndexName': 'client_id',
'FilterExpression': '#filattr0 = :filattrval0',
'KeyConditionExpression': '#keyindexattr0 = :keyindexvalue0',
'ExpressionAttributeNames': {
'#filattr0': 'status',
'#keyindexattr0': 'client_id'
},
'ExpressionAttributeValues': {
':filattrval0': {'S': 'pending'},
':keyindexvalue0': {'S': '00000000-0000-0000-000000000000'}
},
'Limit': 100,
'ConsistentRead': False,
'Select': 'ALL_ATTRIBUTES'}
I get the following response from the database:
# UUIDs have once again been removed, just in case...
{'Items': [{
'modify_date': {'S': '1542637150'},
'template_id': {'S': '00000000-0000-0000-000000000000'},
'software_version': {'S': '0.1'},
'client_id': {'S': '00000000-0000-0000-000000000000'},
'status': {'S': 'pending'},
'timezone': {'S': 'PDT'},
'time': {'S': '1542646800'},
'schedule_id': {'S': '00000000-0000-0000-000000000000'}
}],
'Count': 1,
'ScannedCount': 8,
'ResponseMetadata': {
'RequestId': '*blahblahblah*',
'HTTPStatusCode': 200,
'HTTPHeaders': {
'server': 'Server',
'date': 'Tue, 20 Nov 2018 07:55:59 GMT',
'content-type': 'application/x-amz-json-1.0',
'content-length': '348',
'connection': 'keep-alive',
'x-amzn-requestid': '*blahblahblah*',
'x-amz-crc32': '1922642857'
},
'RetryAttempts': 0}}
What is it about my FilterExpression that is keeping this from working? I've been examining it for hours, and can't see the forest for the trees. I read the documentation extensively, and I think i've covered everything.
Any help or insight anybody could offer would b greatly appreciated...
amazon-web-services amazon-dynamodb boto3 dynamodb-queries
I am really baffled as to what I am doing wrong. It seems like the request I am making to the boto3 dynamodb client is perfect from what I can tell, but I am still not getting any results when I run the query. I suspect it's something to do with the FilterExpression, but I can't fathom it.
I am using a zappa/flask combo to build a web app, and I'm using dynamodb as the database. My AWS credentials and permissions are fine--I know that because I can run simpler queries just fine. Beyond that, the wider context of the application isn't relevant to my question.
I am running the following commands within the context of an object:
args = {... see below ...}
self.db = boto3.client('dynamodb')
self.db.query(**args)
Below is the args argument that I send to the client:
{"TableName": "clients",
"IndexName": "client_id",
"FilterExpression": "#filattr0 < :filattrval0 AND #filattr1 = :filattrval1",
"KeyConditionExpression": "#keyindexattr0 = :keyindexvalue0",
"ExpressionAttributeNames": {
"#filattr0": "time",
"#filattr1": "status",
"#keyindexattr0": "client_id"
},
"ExpressionAttributeValues": {
":filattrval0": {"N": "1542696080"},
":filattrval1": {"S": "pending"},
":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
"Limit": 100,
"ConsistentRead": false,
"Select": "ALL_ATTRIBUTES"}
The response I get back from this query is the following:
{'Items': ,
'Count': 0,
'ScannedCount': 8,
'ResponseMetadata': {'RequestId': '*blahblahblah*',
'HTTPStatusCode': 200,
'HTTPHeaders': {
'server': 'Server',
'date': 'Tue, 20 Nov 2018 06:41:20 GMT',
'content-type': 'application/x-amz-json-1.0',
'content-length': '39',
'connection': 'keep-alive',
'x-amzn-requestid': '*blahblahblah*',
'x-amz-crc32': '*numbers*'},
'RetryAttempts': 0
}}
Now, I am looking at the dynamodb table through my AWS Console, and it is showing me the following object in the appropriate table. In fact, when I construct this query in the table view of the dynamodb console on the AWS Website, it returns the following object, so I know the parameters are acceptable to AWS:
# Taken from the JSON view of the item in the database
# I removed the UUIDs just in case...
{
"client_id": "00000000-0000-0000-000000000000",
"modify_date": "1542637150",
"schedule_id": "00000000-0000-0000-000000000000",
"software_version": "0.1",
"status": "pending",
"template_id": "00000000-0000-0000-000000000000",
"time": "1542646800",
"timezone": "PDT"
}
The weirdest thing is that when I run the query using the following args variable:
{'TableName': 'hmcmSchedule',
'IndexName': 'client_id',
'FilterExpression': '#filattr0 = :filattrval0',
'KeyConditionExpression': '#keyindexattr0 = :keyindexvalue0',
'ExpressionAttributeNames': {
'#filattr0': 'status',
'#keyindexattr0': 'client_id'
},
'ExpressionAttributeValues': {
':filattrval0': {'S': 'pending'},
':keyindexvalue0': {'S': '00000000-0000-0000-000000000000'}
},
'Limit': 100,
'ConsistentRead': False,
'Select': 'ALL_ATTRIBUTES'}
I get the following response from the database:
# UUIDs have once again been removed, just in case...
{'Items': [{
'modify_date': {'S': '1542637150'},
'template_id': {'S': '00000000-0000-0000-000000000000'},
'software_version': {'S': '0.1'},
'client_id': {'S': '00000000-0000-0000-000000000000'},
'status': {'S': 'pending'},
'timezone': {'S': 'PDT'},
'time': {'S': '1542646800'},
'schedule_id': {'S': '00000000-0000-0000-000000000000'}
}],
'Count': 1,
'ScannedCount': 8,
'ResponseMetadata': {
'RequestId': '*blahblahblah*',
'HTTPStatusCode': 200,
'HTTPHeaders': {
'server': 'Server',
'date': 'Tue, 20 Nov 2018 07:55:59 GMT',
'content-type': 'application/x-amz-json-1.0',
'content-length': '348',
'connection': 'keep-alive',
'x-amzn-requestid': '*blahblahblah*',
'x-amz-crc32': '1922642857'
},
'RetryAttempts': 0}}
What is it about my FilterExpression that is keeping this from working? I've been examining it for hours, and can't see the forest for the trees. I read the documentation extensively, and I think i've covered everything.
Any help or insight anybody could offer would b greatly appreciated...
amazon-web-services amazon-dynamodb boto3 dynamodb-queries
amazon-web-services amazon-dynamodb boto3 dynamodb-queries
asked Nov 20 '18 at 8:09
user3628576user3628576
146
146
IMHO, the best place for database related question is dba.stackexchange.com . BTW, this is not a boto3 question.
– mootmoot
Nov 20 '18 at 10:18
According to the output of the successful query, it looks liketime
wasn't stored as a number, but as a string:'time': {'S': '1542646800'},
I might be wrong but comparing this to a number seems problematic.
– Michael - sqlbot
Nov 20 '18 at 12:56
@Michael-sqlbot, I don't think it's that time was stored as a string, as the datatype in the database is number. It is odd that it was returned as a string, but the documentation did say that dynamodb sends and receives all values as strings. So it may just be a quirk of the system.
– user3628576
Nov 20 '18 at 15:44
add a comment |
IMHO, the best place for database related question is dba.stackexchange.com . BTW, this is not a boto3 question.
– mootmoot
Nov 20 '18 at 10:18
According to the output of the successful query, it looks liketime
wasn't stored as a number, but as a string:'time': {'S': '1542646800'},
I might be wrong but comparing this to a number seems problematic.
– Michael - sqlbot
Nov 20 '18 at 12:56
@Michael-sqlbot, I don't think it's that time was stored as a string, as the datatype in the database is number. It is odd that it was returned as a string, but the documentation did say that dynamodb sends and receives all values as strings. So it may just be a quirk of the system.
– user3628576
Nov 20 '18 at 15:44
IMHO, the best place for database related question is dba.stackexchange.com . BTW, this is not a boto3 question.
– mootmoot
Nov 20 '18 at 10:18
IMHO, the best place for database related question is dba.stackexchange.com . BTW, this is not a boto3 question.
– mootmoot
Nov 20 '18 at 10:18
According to the output of the successful query, it looks like
time
wasn't stored as a number, but as a string: 'time': {'S': '1542646800'},
I might be wrong but comparing this to a number seems problematic.– Michael - sqlbot
Nov 20 '18 at 12:56
According to the output of the successful query, it looks like
time
wasn't stored as a number, but as a string: 'time': {'S': '1542646800'},
I might be wrong but comparing this to a number seems problematic.– Michael - sqlbot
Nov 20 '18 at 12:56
@Michael-sqlbot, I don't think it's that time was stored as a string, as the datatype in the database is number. It is odd that it was returned as a string, but the documentation did say that dynamodb sends and receives all values as strings. So it may just be a quirk of the system.
– user3628576
Nov 20 '18 at 15:44
@Michael-sqlbot, I don't think it's that time was stored as a string, as the datatype in the database is number. It is odd that it was returned as a string, but the documentation did say that dynamodb sends and receives all values as strings. So it may just be a quirk of the system.
– user3628576
Nov 20 '18 at 15:44
add a comment |
1 Answer
1
active
oldest
votes
No, @Michael-sqlbot was right. The issue turned out to be a combination of problems that I just didn't pick up on. I had everything correct but the portion where I was specifying the ExpressionAttributeValues:
So this:
"ExpressionAttributeValues": {
":filattrval0": {"N": "1542696080"},
":filattrval1": {"S": "pending"},
":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
Was entirely correct. The problems I kept having were that I would switch databases without switching attributes, the parameters I set didn't match anything in the database, or--as @Michael-sqlbot pointed out--the value of time stored in the database was of a different datatype.
You can't compare a number against a string, as it turns out. And since I was debugging from Zappa tail --since 5m, I often wound up looking at the wrong material.
So I was right, the code does work, i'm not insane, and I shouldn't code when i'm really tired.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388677%2fwhy-wont-boto3s-filterexpression-accept-more-than-1-expression%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
No, @Michael-sqlbot was right. The issue turned out to be a combination of problems that I just didn't pick up on. I had everything correct but the portion where I was specifying the ExpressionAttributeValues:
So this:
"ExpressionAttributeValues": {
":filattrval0": {"N": "1542696080"},
":filattrval1": {"S": "pending"},
":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
Was entirely correct. The problems I kept having were that I would switch databases without switching attributes, the parameters I set didn't match anything in the database, or--as @Michael-sqlbot pointed out--the value of time stored in the database was of a different datatype.
You can't compare a number against a string, as it turns out. And since I was debugging from Zappa tail --since 5m, I often wound up looking at the wrong material.
So I was right, the code does work, i'm not insane, and I shouldn't code when i'm really tired.
add a comment |
No, @Michael-sqlbot was right. The issue turned out to be a combination of problems that I just didn't pick up on. I had everything correct but the portion where I was specifying the ExpressionAttributeValues:
So this:
"ExpressionAttributeValues": {
":filattrval0": {"N": "1542696080"},
":filattrval1": {"S": "pending"},
":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
Was entirely correct. The problems I kept having were that I would switch databases without switching attributes, the parameters I set didn't match anything in the database, or--as @Michael-sqlbot pointed out--the value of time stored in the database was of a different datatype.
You can't compare a number against a string, as it turns out. And since I was debugging from Zappa tail --since 5m, I often wound up looking at the wrong material.
So I was right, the code does work, i'm not insane, and I shouldn't code when i'm really tired.
add a comment |
No, @Michael-sqlbot was right. The issue turned out to be a combination of problems that I just didn't pick up on. I had everything correct but the portion where I was specifying the ExpressionAttributeValues:
So this:
"ExpressionAttributeValues": {
":filattrval0": {"N": "1542696080"},
":filattrval1": {"S": "pending"},
":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
Was entirely correct. The problems I kept having were that I would switch databases without switching attributes, the parameters I set didn't match anything in the database, or--as @Michael-sqlbot pointed out--the value of time stored in the database was of a different datatype.
You can't compare a number against a string, as it turns out. And since I was debugging from Zappa tail --since 5m, I often wound up looking at the wrong material.
So I was right, the code does work, i'm not insane, and I shouldn't code when i'm really tired.
No, @Michael-sqlbot was right. The issue turned out to be a combination of problems that I just didn't pick up on. I had everything correct but the portion where I was specifying the ExpressionAttributeValues:
So this:
"ExpressionAttributeValues": {
":filattrval0": {"N": "1542696080"},
":filattrval1": {"S": "pending"},
":keyindexvalue0": {"S": "00000000-0000-0000-000000000000"}
},
Was entirely correct. The problems I kept having were that I would switch databases without switching attributes, the parameters I set didn't match anything in the database, or--as @Michael-sqlbot pointed out--the value of time stored in the database was of a different datatype.
You can't compare a number against a string, as it turns out. And since I was debugging from Zappa tail --since 5m, I often wound up looking at the wrong material.
So I was right, the code does work, i'm not insane, and I shouldn't code when i'm really tired.
answered Nov 20 '18 at 16:59
user3628576user3628576
146
146
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388677%2fwhy-wont-boto3s-filterexpression-accept-more-than-1-expression%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
IMHO, the best place for database related question is dba.stackexchange.com . BTW, this is not a boto3 question.
– mootmoot
Nov 20 '18 at 10:18
According to the output of the successful query, it looks like
time
wasn't stored as a number, but as a string:'time': {'S': '1542646800'},
I might be wrong but comparing this to a number seems problematic.– Michael - sqlbot
Nov 20 '18 at 12:56
@Michael-sqlbot, I don't think it's that time was stored as a string, as the datatype in the database is number. It is odd that it was returned as a string, but the documentation did say that dynamodb sends and receives all values as strings. So it may just be a quirk of the system.
– user3628576
Nov 20 '18 at 15:44