On Jun 9, 8:16 am, Evgeni Dzhelyov <[email protected]> wrote:
> Using single thread environment or something like Rack::Lock will do the
> trick.
>
> I found the solution by Jeremy to me cleaner and explicit and
> basically what I needed, a way to lock the db connection.
> After reviewing and playing some more I decided to abandon this
> approach as the benefits are only to have fewer models in my case.
> I'm using explicit schema prefix in the models like this :
>
> module A
> class S < Sequel::Model(a__s)
> end
> end
>
> Do you know how could I setup table_prefix based on the module and not
> set it explicity ?
Override Sequel::Model.implicit_table_name:
class Sequel::Model
def self.implicit_table_name
mod, name = name().to_s.split('::')
name ? Sequel::SQL::QualifiedIdentifier.new(underscore(mod),
pluralize(underscore(name))) : super
end
end
Unfortunately, this doesn't work currently, as set_dataset only
accepts Symbols and Datasets as arguments (it should probably accept
SQL::Identifiers and SQL::QualifiedIdentifiers and treat them like
Symbols). I'll fix that. This is uglier but should work with the
current code:
class Sequel::Model
def self.implicit_table_name
mod, name = name().to_s.split('::')
name ? :"#{underscore(mod)}__#{pluralize(underscore(name))}" :
super
end
end
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.