Thanks for the suggestions, I've tried this with the gist here <https://gist.github.com/Nogbit/759d4d271f3bb2a5983c> and nothing seems to change when using my models.
On Friday, July 17, 2015 at 3:55:55 PM UTC-7, Jeremy Evans wrote: > > On Friday, July 17, 2015 at 4:35:35 PM UTC-6, [email protected] <javascript:> > wrote: >> >> DataMapper creates its columns with underscores from camel cased model >> properties, which leaves me with the following situation... >> >> DataMapper model.... >> "Artist.firstName" in mysql is defined as "Artist.first_name" >> >> Using a Sequel model, I have to do >> "Artist.first_name" >> >> This of course forces me to change everything downstream. I would like >> to not have to explicitly have some custom method for every Sequel model >> property to fix this, is there something on the model class itself that >> will help or is there something else you could suggest? >> > > You are using snake_case in the database and want to use camelCase in > ruby, despite the case that virtually all ruby developers use snake_case? :) > > There's a couple of different issues if you want to rename identifiers. > At the model level, you can always just alias the column methods: > > class Artist < Sequel::Model > alias firstName first_name > alias firstName= first_name= > end > > If you want to handle renamed identifiers inside dataset filters, so that > things like Artist.where(:firstName=>'foo') will work, you need to modify > the literalization of identifiers. If you want to automatically convert > snake_case to camelCase for all identifiers in the database: > > Sequel.extension :inflector > DB.identifier_input_method = :underscore > > You could also try setting: > > class String > def camel_case > s = camelize > s[0] = s[0].downcase > s > end > end > DB.identifier_output_method = :underscore > > That should remove the need to alias in your models, as it will allow you > to use camelCase in your ruby code, while keeping the database identifiers > in snake_case. > > Thanks, > Jeremy > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
