In the mean time, to get this fixed so I can move on, I'd like to sub-
class Sequel::Model into something like MyCustomBaseClass, so I can
override the #implicit_table_name method without overriding the
original, e.g.

class MyCustomBaseClass < Sequel::Model
  remove_instance_variable(:@dataset)
  # <override implicit_table_name here>
end

class Person < MyCustomBaseClass
  primary_key :id
end

>From looking at the code, removing the @dataset instance variable
seems like the only thing I need to do for this to work (a quick test
confirmed it worked, as far as I can tell). Is this the best way to
make a custom base class from Sequel::Model, or is there a better way?

Cheers

On Feb 6, 5:05 pm, Tom Wardrop <[email protected]> wrote:
> In our organisation, we've decided that table names should be
> singular, i.e. they should represent the objects/rows they store,
> rather than refer to the collection as a whole. So instead of having a
> People table, we'd have a Person table. It can simplify the code as
> well, as you don't need to remember where to use the plural form, and
> where to use the singular form - inflections are in my personal
> opinion, a band-aid to what should be a non-issue.
>
> Anyway, Sequel I've noticed is always the friendliest in regards to
> this table naming scheme. I've had to turn off inflections by clearing
> all the inflections. The problem with doing this is that while it
> clears the table name inflections, it also clears the method name
> inflections (e.g the add_* and remove_* methods for many to many/one
> relationships don't read properly). It seems hypocritical for me to
> rant about how I don't like inflections, only to task for them in this
> particular instance. Ideally, I'd like not to use inflections, but
> Sequel's association API makes it awkward NOT to use inflections.
>
> There's a couple of ways this issue of association method names could
> be alleviated. If the add_* method for many-to-many relationships took
> multiple model's, e.g. group.add_people(Person1, Person2, ...), then
> all of a sudden the pluralized association name is no longer awkward,
> plus you've just made this particular method more useful. An
> alternative solution would be to define the singular name for this
> methods as an option when defining the association, as an example, my
> association may look like this: many_to_many :people, :class
> => :Person, :singular_name => 'person'. Finally, a third solution
> would be to provide a way to disable table name inflections while
> maintaining association inflections.
>
> I'm confident Jeremy can think of a nice solution here that
> accommodates us singular table name users.
>
> Cheers,
> Tom

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to