Skip to content

MATCH with neotime.Datetime params on value datetime("2019-10-30T07:54:02.129790999[UTC]") #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
huumq00731 opened this issue Oct 31, 2019 · 5 comments
Labels

Comments

@huumq00731
Copy link

huumq00731 commented Oct 31, 2019

Example bug report

Can not MATCH with datetime value: "2019-10-30T07:54:02.129790999[UTC]

Neo4j Version: : 3.5.11 Community
Neo4j Mode: Single instance
Driver version: Python driver 1.7.5
(Python lib: neo4j==1.7.5, neobolt==1.7.15, neotime==1.7.4)
Operating System: Window 10 64bit

Steps to reproduce

  1. Start Neo4j.

  2. Run a query with browser:
    CREATE (t:TEST {update_date:datetime("2019-10-30T07:54:02.129790999[UTC]")})

  3. Run python code

from neo4j import GraphDatabase
from neobolt.security import ENCRYPTION_OFF

driver = GraphDatabase.driver("bolt://127.0.0.1:7687", auth=("neo4j", "mchc2019"), encrypted=ENCRYPTION_OFF)
with driver.session() as session:
    search_query = "MATCH (t:TEST) RETURN t"
    result = session.run(search_query)
    for record in result.records():
        print(record["t"])
        last_date = record["t"].get("update_date")
        
    search_query1 = "MATCH (t:TEST) WHERE t.update_date=$last_date RETURN t"
    result1 = session.run(search_query1, last_date=last_date)
    for record1 in result1.records():
        print(record1["t"])

Expected behavior

Out put is:

<Node id=248 labels={'TEST'} properties={'update_date': neotime.DateTime(2019, 10, 30, 7, 54, 2.129790999, tzinfo=)}>
Have record
<Node id=248 labels={'TEST'} properties={'update_date': neotime.DateTime(2019, 10, 30, 7, 54, 2.129790888, tzinfo=)}>

Actual behavior

Out put is:

<Node id=248 labels={'TEST'} properties={'update_date': neotime.DateTime(2019, 10, 30, 7, 54, 2.129790999, tzinfo=)}>

@huumq00731
Copy link
Author

huumq00731 commented Oct 31, 2019

Same problem with datetime value = "2019-10-31T05:41:16.065365999[UTC]"

@technige
Copy link
Contributor

technige commented Jan 2, 2020

Looks like a possible rounding/precision issue, likely around passing neotime.DateTime values in as parameters. This issue can be more succinctly recreated using the code below:

>>> from neo4j import GraphDatabase
>>> d = GraphDatabase.driver("bolt://", auth=("neo4j", "password"))
>>> s = d.session()
>>> dt1 = s.run("RETURN datetime('2019-10-30T07:54:02.129790999[UTC]')").single().value()
>>> dt2 = s.run("RETURN $x", x=dt1).single().value()
>>> dt1
neotime.DateTime(2019, 10, 30, 7, 54, 2.129790999, tzinfo=<UTC>)
>>> dt2
neotime.DateTime(2019, 10, 30, 7, 54, 2.129790998, tzinfo=<UTC>)

@martin-neotech
Copy link
Contributor

This have been fixed with PR #412 for the upcoming 4.0.0 driver.

@martin-neotech
Copy link
Contributor

@martin-neotech
Copy link
Contributor

For driver 1.7 that uses neotime this PR have been merged now. neo4j-drivers/neotime#10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants