On Jun 3, 6:23 pm, Hiten <[email protected]> wrote:
> On Jun 2, 8:01 pm, Jeremy Evans <[email protected]> wrote:
> What would you do in a situation where the particular table had no
> relation to the id? For instance, each row is identified by a table
> number and id (e.g., [ 7 , 1234 ] would signify Table07 and row id
> 1234).

In that case, instead of basing it on the id, you would just use the
table number:

  def this
    super.from(:"TABLE#{sprintf('%03i', table_number)}")
  end

> Seems that the table name would need to be accessible somewhere. Is
> the table name accessible from a Sequel model instance?

  model_instance.model.table_name
  model_instance.this.first_source

Will give the table name for the model and instance, respectively.  I
would actually recommend doing this:

  def this
    super.from(:"TABLE#{sprintf('%03i',
table_number)}".as(:some_table_name))
  end

That way, no matter what the underlying table name is, you can always
refer to it by the same alias.

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