Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Empty string in database becomes None value in Python

オープン
#570 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
database

調査の方向性

まず、示されている Flux クエリで Python の再現コードを実行し、期待される _value の値と実際の値を比較します。query_api().query(q) が返されたレコードをどのように解析するかを追跡し、その後、空の文字列が結果内で None になるのではなく "" のまま保持されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

bug
Specifications
  • Client Version: 1.34.0
  • InfluxDB Version: 2.6.1
  • Platform: Linux
Code sample to reproduce problem
import influxdb_client

with influxdb_client.InfluxDBClient(
    org = ...,
    token = ...,
    url = ...,
) as client:
    q = f"""
        from(bucket: ...)
        //|> filter(fn: (r) => exists r._value)
        //|> filter(fn: (r) => r._value != "")
        |> last()
    """
    res = [
        record_it.values
        for table_it in client.query_api().query(q)
        for record_it in table_it.records
    ]
    print(res)
Expected behavior

[{'result': '_result', 'table': 0, '_time': datetime.datetime(2023, 3, 2, 18, 47, 7, 547036, tzinfo=tzutc()), '_value': ''}]

Actual behavior

[{'result': '_result', 'table': 0, '_time': datetime.datetime(2023, 3, 2, 18, 47, 7, 547036, tzinfo=tzutc()), '_value': None}]

Additional info

last() function:

If [_value] column is null in the last record, last() returns the previous record with a non-null value.

My last record with a non-null _value has the empty string for _value.
So far, the row is correctly identified.
But by the time I read _value from the result returned in Python, the record does not hold the empty string "" but None.

I verified that the value of _value is really the empty string in the database and not None by experimenting with filters (see commented code).
I find it more intuitive to leave the empty string as empty string in Python.

主要言語
Python
スター
792
フォーク
186
平均マージ
3時間 2分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

influxdata/influxdb-client-python のほかの issue

influxdata/influxdb-client-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。