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

Parameters are auto-converted to float #705

Closed
szarnyasg opened this issue Feb 23, 2018 · 0 comments
Closed

Parameters are auto-converted to float #705

szarnyasg opened this issue Feb 23, 2018 · 0 comments

Comments

@szarnyasg
Copy link

szarnyasg commented Feb 23, 2018

Version: 3.3.3

Running the following expression returns 3

RETURN 10 / 3 AS x
╒═══╕
│"x"│
╞═══╡
│3  │
└───┘

However, when running the same expression with a parameter, it (presumably) does an automatic conversion to float and returns 3.33...

:param {par: 10}
RETURN $par / 3 AS x
╒══════════════════╕
│"x"               │
╞══════════════════╡
│3.3333333333333335│
└──────────────────┘

The conversion happens around the web UI.

I have hastily written some code to demonstrate that using parameters on their own is not sufficient to get an automatic floating point conversion (neither when using the embedded database, nor the driver).

GraphDatabaseSettings.BoltConnector bolt = GraphDatabaseSettings.boltConnector("0");

GraphDatabaseService graphDb = new GraphDatabaseFactory()
        .newEmbeddedDatabaseBuilder( new File("/tmp/db") )
        .setConfig("apoc.import.file.enabled", "true")
        .setConfig(bolt.type, "BOLT")
        .setConfig(bolt.enabled, "true")
        .setConfig(bolt.address, "localhost:7688")
        .newGraphDatabase();

Result result = graphDb.execute(
        "RETURN $par / 3 AS x", ImmutableMap.of("par", 10)
);
System.out.println(result.next());

Driver driver = GraphDatabase.driver("bolt://localhost:7688");
Transaction tx = driver.session().beginTransaction();
StatementResult result2 = tx.run(
        "RETURN $par / 3 AS x", ImmutableMap.of("par", 10)
);
System.out.println(result2.next());

This returns:

{x=3}
Record<{x: 3}>
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