![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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, rder => 'name', :conditions => { :disabled_at=> !nil } SELECT * FROM "groups" WHERE ("groups"."disabled_at" = 't') ORDER BY name or named_scope :disabled, rder => 'name', :conditions => ['disabled_at?', nil] SELECT * FROM "groups" WHERE (disabled_at <> NULL) ORDER BY name --~--~---------~--~----~------------~-------~--~----~ |
#3
| |||
| |||
|
|
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, rder => 'name', :conditions => { :disabled_at=> !nil } SELECT * FROM "groups" WHERE ("groups"."disabled_at" = 't') ORDER BY name or named_scope :disabled, rder => 'name', :conditions => ['disabled_at?', nil] SELECT * FROM "groups" WHERE (disabled_at <> NULL) ORDER BY name |
#4
| |||
| |||
|
|
Lee Smith wrote: 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, rder => 'name', :conditions => { :disabled_at=> !nil } SELECT * FROM "groups" WHERE ("groups"."disabled_at" = 't') ORDER BY name or named_scope :disabled, rder => '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. |
|
Best, -- Marnen Laibow-Koser http://www.marnen.org marnen (AT) marnen (DOT) org |
#5
| |||
| |||
|
| named_scope :disabled, rder => '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. |
|
Best, -- Marnen Laibow-Koserhttp://www.marnen.org mar... (AT) marnen (DOT) org -- Posted viahttp://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ |
![]() |
| Thread Tools | |
| Display Modes | |
| |