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

Fixing issue on gen.resource.browser with some column types #997

Merged
merged 2 commits into from
Feb 10, 2020

Conversation

jwoertink
Copy link
Member

Purpose

Fixes #995

Description

Prior to this, the gen.resource.browser task would fail if you tried to generate a JSON::Any column or any of the Array column types. We were just doing a simple split on : which didn't really work for JSON::Any.

Checklist

  • - An issue already exists detailing the issue/or feature request that this PR fixes
  • - All specs are formatted with crystal tool format spec src
  • - Inline documentation has been added and/or updated
  • - Lucky builds on docker with ./script/setup
  • - All builds and specs pass on docker with ./script/test

…ing JSON and Array fields now that they're supported. Fixes #995
Copy link
Member

@paulcsmith paulcsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This has definitely tripped people up!

I’d like to suggest a change to the approach though. The generators don’t really support json any or array types and I can’t think of a good way to do handle inputs and show those types. I think it would be ok for people to add those columns themselves since we can’t really do it for them reliably.

So I think we can have an array of “supported types” such as String, Time, Ints. Then we check that they type is in the supported types and if not raise an error letting them know what the supported types are

I think this would also make the test simpler since you could pass a non supported type and check for a printed error.

I also think you could still use split since JSON::Any isn’t supported anyway. Thoughts?

@jwoertink
Copy link
Member Author

I'm down for that too. I forgot about creating the inputs. I guess we can say that the generators are only meant for a basic "getting started" point, and any complex thing needs to be done manually. We should probably do up a whole deal on the guides on generators and mention that.

Ok, so I'll change this up to check specifically for the simple types that we support, and then any others will raise an error message. Do you think the error message should say something like "If you need to use JSON or Arrays, you will need to add those in manually"?

@paulcsmith
Copy link
Member

paulcsmith commented Jan 6, 2020 via email

@paulcsmith
Copy link
Member

Also I think split takes a second argument that’s an int. So if you pass 2 it will stop splitting after the first colon. That’s how it is in ruby and hopefully in crystal too 😆

…e support to be generated. More complex types like Array and JSON should just be added manually due to other generators not being able to support them.
Copy link
Member

@paulcsmith paulcsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to merge this as-is because it is a HUGE improvement. If you have time though could you add a followup PR that adjust the wording from valid/invalid to supported/unsupported?

  • VALID_TYPES -> SUPPORTED_TYPES
  • Must provide support columns for the resource

and changing method names like `validate_has_supported_columns. Thoughts?

@paulcsmith paulcsmith merged commit 9cb7a5d into master Feb 10, 2020
@paulcsmith paulcsmith deleted the bugs/995 branch February 10, 2020 22:56
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

Successfully merging this pull request may close these issues.

Error with gen.resource.browser when using JSON
2 participants