chronogolf / sisense

MIT License
3 stars 6 forks source link

`parameterize` function converts booleans to null #6

Closed kcarmonamurphy closed 4 years ago

kcarmonamurphy commented 4 years ago

Hi Olivier,

I wanted to first say great work on this gem, thank you for your hard work!

I'm running into an issue with the parameterize() function in this file: https://github.com/chronogolf/sisense/blame/master/lib/sisense/api/client.rb#L107. If there are boolean ruby values in the object being passed in, the resulting return object seems to have any boolean values, whether true or false converted to null.

I was wondering what the purpose of this function is? When I tried using .to_json instead of parameterize() on my object, I got the results I desired, and boolean values correctly converted to their json counterparts.

Would love to hear your thoughts.

Kevin

olimart commented 4 years ago

Cc. @olivierbuffon

olivierbuffon commented 4 years ago

@kcarmonamurphy thanks for the kind words, appreciated! Well here it sounds to me like an unexpected behaviour, I guess it's a side effect we did not experience or realize at the time I worked on this gem. Unfortunately since I'm not officially working for Chronogolf anymore, I'm not considered as maintainer of this code, but I'm sure a contribution on this would be really appreciated. => @11factory @rothlis might be able to look into it with you?

Cheers.

kcarmonamurphy commented 4 years ago

thanks @olivierbuffon for the quick response. for context @11factory and @rothlis , I'm trying to implement a data security rule in Sisense using the /elasticubes/datasecurity endpoint.

In our code we have:

params = [{:allMembers=>true,
  :members=>[],
  :column=>"column_id",
  :shares=>[{:type=>"group", :party=>"party_id"}],
  :elasticube=>"Elasticube",
  :table=>"Table",
  :server=>"localhost",
  :datatype=>"numeric"}]

which after passing through the parameterize(params) function yields:

[{"allMembers"=>nil,
  "members"=>[],
  "column"=>"column_id",
  "shares"=>[{"type"=>"group", "party"=>"party_id"}],
  "elasticube"=>"Elasticube",
  "table"=>"Table",
  "server"=>"localhost",
  "datatype"=>"numeric"}]

Notice that the boolean was mistakenly converted to nil.

The solution that works for us in this instance is simply using params.to_json instead of parameterize(params), however I don't quite know what the implications of this will be for other areas of the API connector.