【问题标题】:Attribute between in filter_expression does not work when mocking DynamoDB using moto使用 moto 模拟 DynamoDB 时,filter_expression 之间的属性不起作用
【发布时间】:2021-12-24 18:07:36
【问题描述】:

我的测试设置如下所示:

    @mock_dynamodb2
    def test_name(self, dynamodb_connection):
        create_table(dynamodb_connection)
        table = dynamodb_connection.Table(os.environ["table"])
        table.put_item(Item=create_item())
        items = get_items()

存储如下记录:

在本地调用以下查询时,在模拟环境中,返回结果:

get_table("table").query(
    IndexName="org-index",
    KeyConditionExpression=Key("org").eq(org),
    FilterExpression=Attr("status").gte(0) & Attr("status").lte(10)

AWS 生产中的相同代码将返回 0 个结果。将查询更改为使用 between 属性 (Attr("status").between(0, 10)) 可在云中的 DynamoDB 上运行,但在本地运行。我不想通过检查将测试与产品代码合并。有什么我忽略的吗?

【问题讨论】:

  • 你能发布表格架构吗?

标签: boto3 dynamodb-queries moto


【解决方案1】:

between(0, 10) 存在一个错误,其中 0 被视为无值。 从 moto >= 2.2.14.dev25 开始,这个问题刚刚得到修复。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多