Skip to content

Named fields#9

Open
nextgenappsllc wants to merge 2 commits intorailslove:masterfrom
nextgenappsllc:named_fields
Open

Named fields#9
nextgenappsllc wants to merge 2 commits intorailslove:masterfrom
nextgenappsllc:named_fields

Conversation

@nextgenappsllc
Copy link

I needed to have a name for methods different for the field name used in queries. In my example I needed anniversary to be from the field named "hire_date" which I later refactored for rehires to "last_hire" and "orig_hire". Now you can pass named parameters with the key being the name used in methods and the value being what you want inserted in the query as follows:

acts_as_birthday(:birthday, anniversary: '(coalesce(last_hire, orig_hire))')

I did take out the back tics around the field name in the mysql adapter where query which is the adapter I am currently using. I have not rewritten for the other adapters.

@nextgenappsllc
Copy link
Author

Is this repo being maintained? If so I can refactor and rewrite for other adapters.

@bumi
Copy link

bumi commented Mar 15, 2017

Hey @nextgenappsllc
I am so sorry that nobody got back to you!! thanks a lot for the pull request!!
@Holek and I are currently not actively working and thus sadly this gem is lacking some maintenance. sorry :(

@Holek could you help looking at this PR? I think it is an interesting change, but have to look closer.
I am happy to merge and release a new version if this is fully backwards compatible.

Also @nextgenappsllc I think we should add some tests if possible?

@nextgenappsllc
Copy link
Author

Thanks for the response @bumi !

This gem has worked great for my enterprise projects, its a shame more people aren't interested in it. I've been pretty busy but can write some tests this weekend. It might be worth it to upgrade the minimum ruby version to 2.0 as well. Thanks again and I'll get back to you after I make the changes.

@bumi
Copy link

bumi commented Mar 22, 2017

yes, @Holek did some great work here. also happy to hear it is helpful for you!
Would be great if you could add some specs, then I will update the ruby version, do some maintenance and release a new version.
Do you see any other things that should be changed quickly?

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.

2 participants