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

Number data type not coerced #125

Closed
jedschneider opened this issue Mar 22, 2017 · 1 comment
Closed

Number data type not coerced #125

jedschneider opened this issue Mar 22, 2017 · 1 comment
Assignees
Labels

Comments

@jedschneider
Copy link

jedschneider commented Mar 22, 2017

create a new space, use the product catalog bootstraped data model

image

Validate the price on the product data type is a Decimal Number

image

with the ruby client bundled from master on this repo,
make a request to /content_types and response encodes the price as a Number type:

{"id"=>"price", "name"=>"Price", "type"=>"Number", "localized"=>false, "required"=>false, "disabled"=>false, "omitted"=>false}

fetch Product entries and you will get a coerce error because the list here does not support the Number type.

I was able to fork the code, pull down the code base and run the tests, but I did not see where you were testing the inclusion of all data types. in the vcr cassettes I see that there are two 'livesLeft' types, but both are integer, I'm wondering if one was intended to be a decimal. Point out where/if you would like a failing test and I can write one, and deliver test and fix on a PR. Maybe this is a broader issue and that the Number data type should not always be considered a decimal type across the wire. I don't know enough about the system to presume you know what you want here but happy to make a contribution since this seems pretty broken.

stacktrace:

/Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/field.rb:42:in `coerce': undefined method `new' for nil:NilClass (NoMethodError)
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/entry.rb:23:in `coerce'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/fields_resource.rb:97:in `block in hydrate_fields'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/fields_resource.rb:96:in `each'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/fields_resource.rb:96:in `hydrate_fields'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/fields_resource.rb:10:in `initialize'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/resource_builder.rb:77:in `new'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/resource_builder.rb:77:in `build_item'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/resource_builder.rb:60:in `block in build_array'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/resource_builder.rb:59:in `map'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/resource_builder.rb:59:in `build_array'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/resource_builder.rb:49:in `run'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/client.rb:284:in `do_build_resource'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/client.rb:221:in `get'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/request.rb:30:in `get'
	from /Users/jed/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/contentful.rb-ddd04aa8629c/lib/contentful/client.rb:158:in `entries'
	from script.rb:48:in `search'
	from script.rb:57:in `<main>'
@dlitvakb
Copy link
Contributor

dlitvakb commented Apr 4, 2017

Hey @jedschneider,

Thanks for noticing this, I'll look into fixing this ASAP.

Cheers

@dlitvakb dlitvakb added the bug label Apr 4, 2017
@dlitvakb dlitvakb self-assigned this Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants