googleapis / googleapis/google-cloud-python

IN operator with `__key__` property does not work

Đang mở
#15,339 1 bình luận 0 reaction 1 người được giao Được @pcostell nhận Xem trên GitHub
api: datastore
Ngôn ngữ chính
Python
Star
5.4k
Fork
1.8k
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
122

Mô tả

Hello,
Sorry I'm not 100% if this should be a bug report or a feature request, but since the IN operator is working on the Datastore UI on the GCP Console I'm guessing it's a bug.

#### Environment details
I'm not allowed to share those, but I don't think it matters in this case

- OS type and version:
- Python version: `python --version`
- pip version: `pip --version`
- `google-cloud-datastore` version: `pip show google-cloud-datastore`

#### Steps to reproduce

1. Try to execute a query on the `__key__` property with the IN operator
2. Error : `ValueError: Invalid key: "[, ]"`

#### Code example

```python
query = client.query(kind=kind)
query.add_filter("__key__", "IN", [client.key(kind, key), client.key(kind, key2)])
```

#### Stack trace
```
# example
```
Sorry I'm not allowed to share the whole stack trace, but I investigated a bit and it seems to come from this condition :
```
if property_name == KEY_PROPERTY_NAME and not isinstance(value, Key):
raise ValueError('Invalid key: "%s"' % value)
```
In case `value` is a `List`, it should check that all elements from the list are Keys instead of raising an error

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.