Skip to content

Commit 729c8d0

Browse files
authored
fix: timestamp field value is null bug (#50)
* fix: timestamp field value is null bug * release 0.0.10
1 parent 23d3f29 commit 729c8d0

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

db_query/manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ tags:
3232
- search
3333
- utilities
3434
type: plugin
35-
version: 0.0.9
35+
version: 0.0.10
3636
privacy: PRIVACY.md
3737
verified: false

db_query/tools/db_util.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,19 @@ def run_query(self, query_sql: str) -> list[dict]:
8282
records = df.to_dict(orient="records")
8383
for record in records:
8484
for key in record:
85-
if type(record[key]) is Timestamp:
86-
record[key] = record[key].strftime('%Y-%m-%d %H:%M:%S')
87-
if type(record[key]) is datetime.date:
88-
record[key] = record[key].strftime('%Y-%m-%d')
89-
if type(record[key]) is UUID:
90-
record[key] = str(record[key])
85+
value = record[key]
86+
# First, check if it is None or an empty string
87+
if value is None or value == '':
88+
continue
89+
if isinstance(value, Timestamp):
90+
record[key] = value.strftime('%Y-%m-%d %H:%M:%S')
91+
if isinstance(value, datetime.date):
92+
record[key] = value.strftime('%Y-%m-%d')
93+
if isinstance(value, UUID):
94+
record[key] = str(value)
95+
elif isinstance(value, float):
96+
if value.is_integer():
97+
record[key] = int(value)
9198
return records
9299

93100
def test_sql(self):

db_query_pre_auth/manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ tags:
3232
- search
3333
- utilities
3434
type: plugin
35-
version: 0.0.9
35+
version: 0.0.10
3636
privacy: PRIVACY.md
3737
verified: false

db_query_pre_auth/tools/db_util.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,19 @@ def run_query(self, query_sql: str) -> list[dict]:
8282
records = df.to_dict(orient="records")
8383
for record in records:
8484
for key in record:
85-
if type(record[key]) is Timestamp:
86-
record[key] = record[key].strftime('%Y-%m-%d %H:%M:%S')
87-
if type(record[key]) is datetime.date:
88-
record[key] = record[key].strftime('%Y-%m-%d')
89-
if type(record[key]) is UUID:
90-
record[key] = str(record[key])
85+
value = record[key]
86+
# First, check if it is None or an empty string
87+
if value is None or value == '':
88+
continue
89+
if isinstance(value, Timestamp):
90+
record[key] = value.strftime('%Y-%m-%d %H:%M:%S')
91+
if isinstance(value, datetime.date):
92+
record[key] = value.strftime('%Y-%m-%d')
93+
if isinstance(value, UUID):
94+
record[key] = str(value)
95+
elif isinstance(value, float):
96+
if value.is_integer():
97+
record[key] = int(value)
9198
return records
9299

93100
def test_sql(self):

0 commit comments

Comments
 (0)