Navigation Menu

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

Add to_s method to SQLServer::Type::Char::Data object #471

Merged

Conversation

marceloeloelo
Copy link
Contributor

@metaskills with the latest introduction of SQLServer::Type::Char::Data object one of the active record serializers that my app is using stopped working.

I chased the issue down to https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_record/type/string.rb#L35 where active record calls value.to_s.

Since value is of type ActiveRecord::ConnectionAdapters::SQLServer::Type::Char::Data it was not doing what is expected.

Since the object doesn't have the to_s implementation it was returning a flat "#<ActiveRecord::ConnectionAdapters::SQLServer::Type::Char::Data:0x000000044a0fe8>" string, instead of returning the actual value from the database, breaking the serializer.

This PR adds just that, to_s implementation. Thoughts?

@metaskills metaskills merged commit e0e29cf into rails-sqlserver:master May 13, 2016
metaskills added a commit that referenced this pull request May 13, 2016
@metaskills
Copy link
Contributor

Good stuff! I added an alias_method :to_str, :to_s which is what ActiveRecord also does for the binary type's #to_s method. Will push this out in v4.2.13 soon.

@marceloeloelo
Copy link
Contributor Author

Thanks @metaskills! Do you have an idea on when v4.2.13 will be released? 😅

@marceloeloelo marceloeloelo deleted the add_to_s_to_char_data_type branch May 19, 2016 12:38
@metaskills
Copy link
Contributor

WHOOPS! Done now :)

@marceloeloelo
Copy link
Contributor Author

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

Successfully merging this pull request may close these issues.

None yet

2 participants