Skip to content
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

nodejs使用neo4j-driver的时候,不支持属性是DATETIME的类型,DATETIME变成了Infinity #690

Closed
lambda-zhang opened this issue Oct 5, 2024 · 2 comments

Comments

@lambda-zhang
Copy link

Environment:

  • OS: Ubuntu 20.04.6 LTS
  • CPU: AMD Ryzen 7 PRO 4750U with Radeon Graphics
  • TuGraph-DB Version 4.3.1

Describe the bug

nodejs使用neo4j-driver的时候,不支持属性是DATETIME的类型,DATETIME变成了Infinity

How to reproduce and expected behavior
main.js:

const neo4j = require('neo4j-driver')
const _url = 'bolt://localhost:7687'
const _auth = neo4j.auth.basic('admin', '123456')
const _database = 'test'
const _options = { disableLosslessIntegers: true, maxTransactionRetryTime: 10000 }

const test = (async () => {
    var driver = neo4j.driver(_url, _auth, _options)
    var session = driver.session({ database: _database })
    try {
        var res = await session.run("return datetime() AS ts")
        for (var i = 0; i < res.records.length; i++) {
            console.log(JSON.stringify(res.records[i]))
            console.log(res.records[i].get("ts"))
            console.log(neo4j.temporal.isDate(res.records[i].get("ts")))
            console.log(neo4j.temporal.isDateTime(res.records[i].get("ts")))
            console.log(neo4j.temporal.isDuration(res.records[i].get("ts")))
            console.log(neo4j.temporal.isLocalDateTime(res.records[i].get("ts")))
            console.log(neo4j.temporal.isLocalTime(res.records[i].get("ts")))
            console.log(neo4j.temporal.isTime(res.records[i].get("ts")))
        }
    } catch (e) {
        console.log(e)
        throw e
    } finally {
        await session.close()
        await driver.close()
    }
})

const main = (async () => {
    await test()
})

main()

package.json:

{
  "dependencies": {
    "neo4j-driver": "5.24.1"
  }
}

运行:

$ node main.js

结果:

Record {
  keys: [ 'ts' ],
  length: 1,
  _fields: [ Infinity ],
  _fieldLookup: { ts: 0 }
}
Infinity
false
false
false
false
false
false
@lambda-zhang
Copy link
Author

TuGraph-DB Version 4.5.0有返回,至少 isLocalDateTime返回true,问题关闭

{"keys":["ts"],"length":1,"_fields":[{"year":2024,"month":10,"day":8,"hour":10,"minute":26,"second":41,"nanosecond":881902000}],"_fieldLookup":{"ts":0}}
LocalDateTime {
  year: 2024,
  month: 10,
  day: 8,
  hour: 10,
  minute: 26,
  second: 41,
  nanosecond: 881902000
}
false
false
false
true
false
false

Copy link

github-actions bot commented Oct 8, 2024

Hello @lambda-zhang, please star this repo if you find it useful! Thanks ⭐!

你好 @lambda-zhang。如果这个项目帮助到你,可以在仓库右上角 star 一下,感谢你的 ⭐!

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

No branches or pull requests

1 participant