Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public static String codegen(String dbname, NodePattern nodePattern) {
res += "Field f = klass.getDeclaredField(property.getName());";
res += "if (property.getType() == long.class) {";
res += "f.setLong(obj, ((Long) property.getValue()));";
res += "} else if (property.getType() == double.class) {";
res += "f.setDouble(obj, ((Double) property.getValue()));";
res += "} else if (property.getType() == String.class) {";
res += "f.set(obj, property.getValue());";
res += "}";
Expand Down
15 changes: 15 additions & 0 deletions estore/src/main/java/org/estore/planner/LogicalPlanBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,21 @@ public Object visitOC_IntegerLiteral(CypherParser.OC_IntegerLiteralContext ctx)
return null;
}

@Override
public Object visitOC_DoubleLiteral(CypherParser.OC_DoubleLiteralContext ctx) {
if (ctx.RegularDecimalReal() != null) {
return new LiteralExpr(
Double.TYPE,
Double.parseDouble(ctx.RegularDecimalReal().getSymbol().getText()));
}
if (ctx.ExponentDecimalReal() != null) {
return new LiteralExpr(
Double.TYPE,
Double.parseDouble(ctx.ExponentDecimalReal().getSymbol().getText()));
}
return null;
}

@Override
public Object visitOC_BooleanLiteral(CypherParser.OC_BooleanLiteralContext ctx) {
if (ctx.TRUE() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public Table execute(Table input) {
Field f = klass.getDeclaredField(property.getName());
if (property.getType() == long.class) {
f.setLong(obj, ((Long) property.getValue()));
} else if (property.getType() == double.class) {
f.setDouble(obj, ((Double) property.getValue()));
} else if (property.getType() == String.class) {
f.set(obj, property.getValue());
}
Expand Down
12 changes: 12 additions & 0 deletions estore/src/test/java/org/estore/CreateInstanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,18 @@ void testNodeAddPropertyCypher2() throws ReflectiveOperationException {
assertEquals(f1.getLong(obj), 30L);
}

@Test
void createObjectWithManyTypes() throws EstoreException {
estore.query("CREATE (n:`ValManyTypes` {i: 30, d: 30.0, s: 'something'}) RETURN n");
Table result = estore.query("MATCH (n:`ValManyTypes`) RETURN n");

assertEquals(1, result.getSize());
Object obj = result.get("n").get(0);
assertEquals(30, estore.getLong(obj, "i"));
assertEquals(30.0, estore.getDouble(obj, "d"), 0.01);
assertEquals("something", estore.getString(obj, "s"));
}

@Test
void testArrayList() throws EstoreException {
ArrayList<Long> a = new ArrayList<Long>();
Expand Down
12 changes: 12 additions & 0 deletions estore/src/test/java/org/estore/compiler/CodeGenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ void testNodeAddPropertyCypher2() throws ReflectiveOperationException {
assertEquals(f1.getLong(obj), 30L);
}

@Test
void createObjectWithManyTypes() throws EstoreException {
estore.query("CREATE (n:`ValManyTypes2` {i: 30, d: 30.0, s: 'something'}) RETURN n");
Table result = estore.query("MATCH (n:`ValManyTypes2`) RETURN n");

assertEquals(1, result.getSize());
Object obj = result.get("n").get(0);
assertEquals(30, estore.getLong(obj, "i"));
assertEquals(30.0, estore.getDouble(obj, "d"), 0.01);
assertEquals("something", estore.getString(obj, "s"));
}

@Test
void testCreateTwoNodeRelation() throws EstoreException {
Table result =
Expand Down
Loading