sirupsen / airrecord

Ruby wrapper for Airtable, your personal database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When to use record[:this_style], record[:'This Style'], or record["This Style"]?

Meekohi opened this issue · comments

When to use record[:this_style], record[:'This Style'], or record["This Style"]? When in doubt, will the latter always work?

Yeah.. good question, when we fetch a record we can normalize it into symbols. However, when you do .new, it doesn't know the schema. I created this design assuming that Airtable would have schemas in the neat future, however, it never seemed to happen. With that in mind, I think it may make sense to always use the record["This Style"] where "This Style" is the exact name of the column.

@chrisfrank wdyt?

fwiw I'd be a supporter of that approach. Converting to symbols is a nice trick and might buy a little efficiency, but creates confusion too.

Do you want to submit a patch for this?

Given that Airtable's schema API never materialized, I'd wholeheartedly support string-only field access. @Meekohi sounds like you're on it, but if you end up not having time, just @ me. I'd be happy to work on this.

Yeah I'll try to sit down in the next week or so and put a patch together.

A philosophical question then -- assuming string-only access works correctly right now (I believe it does anyway), should we just update all the documentation/examples/tests to strings, but leave the old behavior around to stay backward compatible with anyone using it that way currently? Maybe also add deprecation notices for symbol access? Or just pull the trigger, make the change, and do a breaking major version update?

@Meekohi good call, yes. First wave is update all examples + update code to always use strings + spit out errors and scream when you use symbols and say they'll disappear soon.