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

Remote database automatically converts Float to Double #1700

Open
lvca opened this issue Aug 23, 2024 · 1 comment
Open

Remote database automatically converts Float to Double #1700

lvca opened this issue Aug 23, 2024 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@lvca
Copy link
Contributor

lvca commented Aug 23, 2024

Test case to reproduce it:

  @Test
  public void testTypes() throws Exception {
    testEachServer((serverIndex) -> {
      Assertions.assertTrue(
          new RemoteServer("127.0.0.1", 2480 + serverIndex, "root", BaseGraphServerTest.DEFAULT_PASSWORD_FOR_TESTS).exists(
              DATABASE_NAME));

      final RemoteDatabase database = new RemoteDatabase("127.0.0.1", 2480 + serverIndex, DATABASE_NAME, "root",
          BaseGraphServerTest.DEFAULT_PASSWORD_FOR_TESTS);

      database.command("sql", "create vertex type SimpleVertex");

      database.begin();

      RemoteMutableVertex nvSaved = database.newVertex("SimpleVertex");
      nvSaved.set("s", "string");
      nvSaved.set("b", true);
      nvSaved.set("oB", true);
      nvSaved.set("f", 1.0f);
      nvSaved.set("oF", 1.0f);
      nvSaved.set("i", 1);
      nvSaved.set("oI", 1);
      Date targetDate = Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant());
      nvSaved.set("fecha", targetDate);
      nvSaved.save();

      database.commit();
      RID rid = nvSaved.getIdentity();
      System.out.println("RID: " + rid.toString() + "\n\n");

      Vertex v = database.lookupByRID(rid).asVertex();
      System.out.println("retrieved: " + v.getIdentity().toString());
      System.out.println("s: " + v.get("s") + " - " + v.get("s").getClass().getName());
      System.out.println("b: " + v.get("b") + " - " + v.get("b").getClass().getName());
      System.out.println("ob: " + v.get("oB") + " - " + v.get("oB").getClass().getName());
      System.out.println("f: " + v.get("f") + " - " + v.get("f").getClass().getName());
      System.out.println("f: " + v.getFloat("f") + " - " + v.getFloat("f").getClass().getName());
      System.out.println("oF: " + v.get("oF") + " - " + v.get("oF").getClass().getName());
      System.out.println("i: " + v.get("i") + " - " + v.get("i").getClass().getName());
      System.out.println("oI: " + v.get("oI") + " - " + v.get("oI").getClass().getName());
      System.out.println("date: " + v.get("fecha") + " - " + v.get("fecha").getClass().getName());
      System.out.println("getDate: " + v.getDate("fecha") + " - " + v.getDate("fecha").getClass().getName());
      System.out.println("targetDate: " + targetDate.getTime() + " --> ret.date: " + v.getDate("fecha").getTime());
    });
  }
@lvca lvca self-assigned this Aug 23, 2024
@lvca lvca added this to the 24.8.1 milestone Aug 23, 2024
@lvca lvca added the bug Something isn't working label Aug 23, 2024
@lvca
Copy link
Contributor Author

lvca commented Aug 23, 2024

The issue is with the remote protocol: every record is serialized using JSON and JSON doesn't have a Float type, but rather a Double type. The server needs to serialize a special metadata attribute "@types" (like with OrientDB) containing the type of each field to be converted on the client side.

@lvca lvca modified the milestones: 24.10.1, 24.11.1 Oct 12, 2024
@lvca lvca modified the milestones: 24.11.1, 24.11.2 Nov 5, 2024
@lvca lvca modified the milestones: 24.11.2, 24.12.1 Dec 9, 2024
@lvca lvca modified the milestones: 24.12.1, 25.1.1 Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant