TuGraph-family / tugraph-db

TuGraph: A High Performance Graph Database.
https://tugraph.org
Apache License 2.0
1.43k stars 191 forks source link

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

Closed lambda-zhang closed 1 month ago

lambda-zhang commented 1 month ago

Environment:

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 commented 1 month ago

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
github-actions[bot] commented 1 month ago

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

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