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