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

Need ability to explicitly define int field values passed to #write_point(s) #120

Closed
jimryan opened this issue Nov 19, 2015 · 3 comments
Closed

Comments

@jimryan
Copy link

jimryan commented Nov 19, 2015

The line protocol now requires that int's be explicitly defined via a trailing 'i' (see influxdata/influxdb#3526).

It's currently impossible to accomplish this using the #write_point/#write_points methods, so you'll wind up with an error like this:

InfluxDB::Error: write failed: field type conflict: input field "foo" on measurement "bar" is type float64, already exists as type integer

I'm happy to work up a PR, but I'm not sure what the best approach is. I don't know that we can simply tack on an 'i' for all Fixnums without breaking things for users currently passing them to float fields.

Right now, my temporary workaround is to add a wrapper class around Fixnum that tacks on an 'i' in its #to_s method, which I then pass to #write_point, but that's not a longterm/ideal solution, unless it's exposed by the gem itself.

@jimryan jimryan changed the title Need ability to explicitly define int field values with #write_point(s) Need ability to explicitly define int field values passed to #write_point(s) Nov 19, 2015
@nlsrchtr
Copy link

nlsrchtr commented Dec 1, 2015

👍

@dmke
Copy link
Contributor

dmke commented Feb 10, 2016

I've run into the same issue. Based on the suggestion by @jimryan, I currently use this workaround:

class InfluxDB::Int64 < Struct.new(:to_i)
  def to_s
    "#{to_i}i"
  end

  alias inspect to_s
end

def int64(value)
  InfluxDB::Int64.new value.to_i
end

# ...

client.write_point series: "foo", values: { bar: int64(42) } 

But I'm all for a generic "i" suffix for Integers. This would be consistent with the other official client implementations:

@toddboom
Copy link
Contributor

This should be fixed now with #131, which I just merged. Let me know if additional support is needed. Thanks!

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

4 participants