Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Creating models backed by tables with double underscores
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Aaron Pfeifer  
View profile  
 More options Aug 5 2011, 7:18 am
From: Aaron Pfeifer <aaron.pfei...@gmail.com>
Date: Fri, 5 Aug 2011 04:18:48 -0700 (PDT)
Local: Fri, Aug 5 2011 7:18 am
Subject: Creating models backed by tables with double underscores

Hey guys -

Prior to Sequel 3.20.0, I could do the following:

  class FooBar < Sequel::Model(DB[Sequel::SQL::Identifier.new(:foo__bar)])
    ...
  end

This would allow me to create a model backed by a table that has double
underscores in it.  After 3.20.0, this causes the following error:

ArgumentError: wrong number of arguments (0 for 1)

/.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
`to_s'

/.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
`hash'

/.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
`sort_by'

/.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
`each'

/.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
`sort_by'

/.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
`hash'

/.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/model.rb:38 :in
`[]'

/.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/model.rb:38 :in
`Model'

This is because the Sequel::Dataset instance has implemented a hash method
which calls #to_s on its options hash.  Since the Sequel::SQL::Identifier
instance is in that options hash, it also has #to_s called on it.  However,
all expressions (including this identifier instance) override #to_s so that
it requires a single argument being the Dataset.

Given that context, is there a more appropriate way to creating models that
are backed by tables with double underscores?

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Evans  
View profile  
 More options Aug 5 2011, 11:51 am
From: Jeremy Evans <jeremyeva...@gmail.com>
Date: Fri, 5 Aug 2011 08:51:17 -0700 (PDT)
Local: Fri, Aug 5 2011 11:51 am
Subject: Re: Creating models backed by tables with double underscores
On Aug 5, 4:18 am, Aaron Pfeifer <aaron.pfei...@gmail.com> wrote:

Assuming you are only using one Database object, just use:

  class FooBar < Sequel::Model(Sequel::SQL::Identifier.new(:foo__bar))
  end

You'll need to update to the latest version of Sequel, as I'm pretty
sure 3.20.0 doesn't support that.

However, the way you are currently doing it should work.  The behavior
you are seeing is still present in the master branch.  It's a bug and
will be fixed shortly.

Thanks,
Jeremy


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Evans  
View profile  
 More options Aug 5 2011, 12:40 pm
From: Jeremy Evans <jeremyeva...@gmail.com>
Date: Fri, 5 Aug 2011 09:40:48 -0700 (PDT)
Local: Fri, Aug 5 2011 12:40 pm
Subject: Re: Creating models backed by tables with double underscores
On Aug 5, 8:51 am, Jeremy Evans <jeremyeva...@gmail.com> wrote:

> However, the way you are currently doing it should work.  The behavior
> you are seeing is still present in the master branch.  It's a bug and
> will be fixed shortly.

Simple fix in https://github.com/jeremyevans/sequel/commit/7fae243155774bcff35e7d6b...

Jeremy


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Pfeifer  
View profile  
 More options Aug 7 2011, 7:47 pm
From: Aaron Pfeifer <aaron.pfei...@gmail.com>
Date: Sun, 7 Aug 2011 16:47:08 -0700 (PDT)
Local: Sun, Aug 7 2011 7:47 pm
Subject: Re: Creating models backed by tables with double underscores

Thanks for the quick turnaround and the suggested workaround!  Works
perfectly :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »