Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-11013

Node.js apache-ignite-client ComplexObjectType does not deserialize nested objects when the nested type is specified as a ComplexObjectType

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • thin client
    • None
    • Debian 9, stretch
      "apache-ignite-client": "^1.0.0"

    • Docs Required

    Description

      I am trying to navigate the Node.js client and discovered this oddity. I'm not sure what the design goal of the type system in the JS client is - is the goal to define some sort of default object, or is to define a schema? The object does not serve as a default object in my tests, so I'm wondering why I'm supposed to feed in actual values and not a schema, like with Mongoose. Nested complex types are also not consistently deserialized:

       

      // Desired behavior: specify nested ComplexObjectType directly as a member, get deserialized nested object back
      
      const nest = new ComplexObjectType({ num: 0 });
      const ty = new ComplexObjectType({ foo: "", nest }); 
      
      // Uncommenting the following line results in the expected value being returned:
      // ty.setFieldType("nest", nest);
      
      const cache = (await igniteClient.getOrCreateCache("myCache"))
      .setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER)
      .setValueType(ty);
      await cache.put(1, {
          foo: "bar",
          nest: { num: 1 }
      });
      
      // Expected output:
      // { foo: "bar",
      //   nest: {
      //     num: 1 } }
      //
      // Actual output:
      // { foo: "bar",
      //   nest: BinaryObject }
      console.dir(await cache.get(1));
      
      // Additionally, not defining 'nest' in the ComplexObjectType and defining it later will throw:
      const nest = new ComplexObjectType({ num: 0 });
      const ty = new ComplexObjectType({ foo: "" }); 
      ty.setFieldType("nest", nest); // -> IgniteClientError: Field "nest" is absent in the complex object type
      
      

       

      Honestly, working with the JS library without types is hugely painful, even with the JS doc. If I am encouraged, I would happily move the Node.js client over to Typescript.

       

      Tom

       

      p.s. This is my first issue on JIRA. If it's not filed in the correct place or doesn't take the right format - sorry

      Attachments

        Activity

          People

            Unassigned Unassigned
            thavlik Thomas Havlik
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified