Skip to content

datetime类型参数会被截断为date类型 #378

@CrazyDY

Description

@CrazyDY

Please check the FAQ documentation before raising an issue

Describe the bug (required)
在使用SessionPool的execute_py方法查询数据时,在传入datetime类型的参数时,会被强转为date类型,导致查询不到符合条件的数据

Your Environments (required)
win11 python3.9

  • OS: uname -a
  • Commit id (e.g. a3ffc7d8)

How To Reproduce(required)

Steps to reproduce the behavior:

  1. 构造数据
    CREATE TAG IF NOT EXISTS date_test(d datetime);
    INSERT VERTEX date_test(d) VALUES "test1":(datetime());
  2. 编写python代码,执行查询语句
    params = {
    'd': datetime.datetime(2025, 7, 6, 2, 55, 48, 613)}
    result_set = NebulaHelper('date_demo').execute_py(
    'MATCH (v) WHERE v.date_test.d <= $d RETURN v',
    params)
    print(result_set.as_primitive())
    输出为:[]
    实际有数据:
Image
  1. debug模式查看,发现
Image Image

在类型判断时,date类型会优先判断,而datetime类型也属于date类型,因此会把实际的时间截断为日期格式

Expected behavior

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions