Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Which finder syntax would be preferred as far as being the most database agnostic?
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
  5 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:
Follow-up To:
Add Cc | Add Follow-up 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 that you hear
 
Lee Smith  
View profile   Translate to Translated (View Original)
 More options 5 Nov, 04:39
From: Lee Smith <autige...@gmail.com>
Date: Wed, 4 Nov 2009 20:39:36 -0800 (PST)
Local: Thurs 5 Nov 2009 04:39
Subject: Which finder syntax would be preferred as far as being the most database agnostic?
Which finder syntax is preferred?  Or are they the same?

I'm developing on sqlite and I've posted the result of each
query...they kind of look the same but not really.  Would this scale
to say, Mysql or Postgres?  Thanks for any advice.

named_scope :disabled, :order => 'name', :conditions => { :disabled_at
=> !nil }
SELECT * FROM "groups" WHERE ("groups"."disabled_at" = 't') ORDER BY
name

or

named_scope :disabled, :order => 'name', :conditions => ['disabled_at
<> ?', nil]
SELECT * FROM "groups" WHERE (disabled_at <> NULL) ORDER BY name


    Reply    Reply to author    Forward  
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.
Tim Lowrimore  
View profile   Translate to Translated (View Original)
 More options 5 Nov, 05:36
From: Tim Lowrimore <tlowrim...@gmail.com>
Date: Wed, 4 Nov 2009 21:36:48 -0800 (PST)
Local: Thurs 5 Nov 2009 05:36
Subject: Re: Which finder syntax would be preferred as far as being the most database agnostic?
I for one prefer the first syntax, since it eliminates SQL from the
ruby code, but that's just my preference.

Cheers,
Tim

On Nov 4, 10:39 pm, Lee Smith <autige...@gmail.com> wrote:


    Reply    Reply to author    Forward  
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.
Discussion subject changed to "Which finder syntax would be preferred as far as being t" by Marnen Laibow-Koser
Marnen Laibow-Koser  
View profile   Translate to Translated (View Original)
 More options 5 Nov, 13:19
From: Marnen Laibow-Koser <rails-mailing-l...@andreas-s.net>
Date: Thu, 5 Nov 2009 14:19:51 +0100
Local: Thurs 5 Nov 2009 13:19
Subject: Re: Which finder syntax would be preferred as far as being t

Use the first syntax -- the second one is incorrect.  I don't know if
this is true in SQLite, but in the other DBs, NULL = NULL returns NULL,
so your <> NULL construct will return TRUE in all cases, and so it is
pointless.  In the first case, Rails automatically generates the proper
syntax.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
--
Posted via http://www.ruby-forum.com/.


    Reply    Reply to author    Forward  
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.
Marnen Laibow-Koser  
View profile   Translate to Translated (View Original)
 More options 5 Nov, 13:22
From: Marnen Laibow-Koser <rails-mailing-l...@andreas-s.net>
Date: Thu, 5 Nov 2009 14:22:53 +0100
Local: Thurs 5 Nov 2009 13:22
Subject: Re: Which finder syntax would be preferred as far as being t

On second thought, *both* are incorrect.  Use :conditions =>
'disabled_at is not null'.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> mar...@marnen.org

--
Posted via http://www.ruby-forum.com/.

    Reply    Reply to author    Forward  
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.
Frederick Cheung  
View profile   Translate to Translated (View Original)
 More options 5 Nov, 13:28
From: Frederick Cheung <frederick.che...@gmail.com>
Date: Thu, 5 Nov 2009 05:28:45 -0800 (PST)
Local: Thurs 5 Nov 2009 13:28
Subject: Re: Which finder syntax would be preferred as far as being t

On Nov 5, 1:19 pm, Marnen Laibow-Koser <rails-mailing-l...@andreas-

s.net> wrote:

> > named_scope :disabled, :order => 'name', :conditions => ['disabled_at
> > <> ?', nil]
> > SELECT * FROM "groups" WHERE (disabled_at <> NULL) ORDER BY name

> Use the first syntax -- the second one is incorrect.  I don't know if
> this is true in SQLite, but in the other DBs, NULL = NULL returns NULL,
> so your <> NULL construct will return TRUE in all cases, and so it is
> pointless.  In the first case, Rails automatically generates the proper
> syntax.

Actually NULL <> NULL is also NULL. Hooray for 3 way logic. (doesn't
mean the OP's would work though). In general I tend to use the hash
form of conditions when possible, but that's not always the case.

Fred


    Reply    Reply to author    Forward  
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 »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google