Skip to content

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

@lambda-zhang

Description

@lambda-zhang

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions