I would love to be able to use the similar subclassing from Base
approach as I did in AR, as that makes codebase more nimble and
flexible down the road (e.g. common methods can all be in Base).  I
think the only mechanism missing in Sequel is a similar
"abstract_class = true" -- I know from Sequel documentation that
Sequel omits this because of a different way of handling STI and
inheritance.  But I guess Sequel didn't get to think of this use case
where abstract_class can work out great in helping refactoring (?).
It's a simple thing to add, I would imagine, and the value is great.
So just my feedback. ;)

Thanks,
Philip

On Oct 12, 10:40 pm, Jeremy Evans <[email protected]> wrote:
> On Oct 12, 7:45 pm, philip <[email protected]> wrote:
>
> > works.  When a subclass of Base now tries to perform a query, for
> > example, Sequel would complain that the table bases doesn't exist in
> > db1.  I know one can do, say,
>
> > module Db1
> >   class A < Sequel::Model(DB1[:a])
> >   ...
> >   end
> > end
>
> This is the recommended way to do what you want.
>
> > But you can see the inelegance (non-DRY-ness) of this, particularly if
> > we are dealing with many tables from an existing database (legacy or
> > not).   Is there a good, easy way in Sequel currently?
>
> It's not that non-DRY.  We're talking about a few extra characters
> max.  If your table names are the same as the implicit ones, you could
> shave off a few characters:
>
> module Db1
>   class A < Sequel::Model(DB1)
>   ...
>   end
> end
>
> If you really want to be able to do:
>
> module Db1
>   class A < Sequel::Model
>   ...
>   end
> end
>
> Then add a Sequel::Model plugin that inspects the class name for the
> enclosing module name and looks for the appropriate database object to
> use from that.  I wouldn't mind refactoring part of Sequel to make
> that easier.
>
> Jeremy

-- 
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