#64 ✓resolved
Jérôme

default_scope incompatibility

Reported by Jérôme | March 6th, 2009 @ 01:11 PM

Hello

Today's searchlogic trunk is incompatible with the new activerecord's default_scope

default_scope :order => :name raises a "private method gsub!' called for :name:Symbol" in searchlogic/lib/searchlogic/search/ordering.rb:67:inorder_as='

default_scope :order => "name" raises a "can't convert nil into String" in searchlogic/lib/searchlogic/search/ordering.rb:67:in gsub!'

I can't figure out why it doesn't work

Regards

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson March 23rd, 2009 @ 02:55 AM

    • State changed from “new” to “open”

    The second error is very strange. I have never seen symbols accepted in the order option for ActiveRecord. Anyways, that makes no sense because of this:

    if order
      @order.gsub!(/(ASC|DESC)/i, value)
    end
    

    I can't call order directly because other methods get triggered when that is changed, so I call the variable directly. Anyways, its not possible for that value to be nil.

  • Jérôme

    Jérôme March 26th, 2009 @ 10:48 AM

    I found another CRITICAL bug which only affects default_scope and not named_scope: using a column modifier will raise a DB error upon the first model load and until you are using a named_scope ! Check out the weird SQL query produced where conditions are called then twice !

    
    class City < ActiveRecord::Base
      default_scope :conditions => { :country_not => "UK" }
      named_scope :is_capital, :conditions => { :capital => true }
    end
    
    
    Loading development environment (Rails 2.3.2)
    >> City.first
    ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: cities.country_not: SELECT * FROM "cities" WHERE ("cities"."country_not" = 'UK') LIMIT 1
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:402:in `catch_schema_changes'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:305:in `select'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:661:in `find_by_sql'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1553:in `find_every'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1510:in `find_initial'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:613:in `find_without_searchlogic'
    	from /opt/local/lib/ruby/gems/1.8/gems/searchlogic-1.6.4/lib/searchlogic/active_record/base.rb:23:in `find'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:623:in `first'
    	from (irb):1
    
    >> City.first
    ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: cities.country_not: SELECT * FROM "cities" WHERE ("cities"."country_not" = 'UK') LIMIT 1
    
    >> City.is_capital.first
    ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: cities.country_not: SELECT * FROM "cities" WHERE ((("cities"."country_not" = 'UK' AND "cities"."capital" = 't')) AND ("cities"."country" != 'UK')) LIMIT 1
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:402:in `catch_schema_changes'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:305:in `select'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:661:in `find_by_sql'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1553:in `find_every'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1510:in `find_initial'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:613:in `find_without_searchlogic'
    	from /opt/local/lib/ruby/gems/1.8/gems/searchlogic-1.6.4/lib/searchlogic/active_record/base.rb:23:in `find'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:183:in `send'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:183:in `method_missing'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope_without_searchlogic'
    	from /opt/local/lib/ruby/gems/1.8/gems/searchlogic-1.6.4/lib/searchlogic/active_record/base.rb:47:in `with_scope'
    	from (__DELEGATION__):2:in `__send__'
    	from (__DELEGATION__):2:in `with_scope'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:182:in `method_missing'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope_without_searchlogic'
    	from /opt/local/lib/ruby/gems/1.8/gems/searchlogic-1.6.4/lib/searchlogic/active_record/base.rb:47:in `with_scope'
    	from (__DELEGATION__):2:in `__send__'
    	from (__DELEGATION__):2:in `with_scope'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:179:in `method_missing'
    	from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:137:in `first'
    	from (irb):3
    	
    >> City.is_capital.first
    => #<City id: 1, name: "Paris", country: "FR", capital: true, created_at: "2009-03-26 14:39:29", updated_at: "2009-03-26 14:39:29">
    
  • Jérôme

    Jérôme March 26th, 2009 @ 10:57 AM

    Please note that mixing named_scope with default_scope will injects twice the same default_scope condition in the SQL query (AR bug).

  • Ben Johnson

    Ben Johnson March 30th, 2009 @ 11:50 AM

    Can you please create a failing test(s), and then I can fix the issue. By test, I mean a test I can run in the searchlogic test suite. I apologize for asking you to do this, but its a new policy I am implementing with my open source projects. I am just very busy and this would help me easily knock out the issue.

  • schof

    schof May 19th, 2009 @ 11:32 AM

    It looks like this comes up for a default scope using :order but only when the search results are empty. I'll see if I can add a test later.

  • Ben Johnson

    Ben Johnson July 30th, 2009 @ 01:37 PM

    • State changed from “open” to “resolved”

    This should be fixed in 2.0. Thanks!

  • frank butler

    frank butler June 22nd, 2019 @ 07:16 AM

    There are some people who are talking about default_scope incompatibility, but the stuff mentioned here is a bit vague. I worked at edubirdie reviews last month. It would be great if someone adds some more facts here so people would be able to get the most of it and understand its essence without making any guesses.

  • frank butler

    frank butler July 10th, 2019 @ 09:18 AM

    Here you can check all point of the comment then you will realize that this is a great plate form where you can discuss the important point of the programming then you will also check all discussion of the many people on the important point of the programming. The design of the site is very good for the users and students, it is very easy to bankatutorial.com understand and language is very easy in which the writer post the comments.

  • martinguptal

    martinguptal October 11th, 2019 @ 09:06 AM

    I am still surprised to know that you are doing some different jobs these days, are you getting some positive response from public or not, if you are getting this then please share with me at pemburyschoolhousenursery.com or you can also send me an email mentioned on "Contact us" button, you have to just click on the button and send me an email, I would try my level best to provide and reply you the same.

  • ishanikappor2019 (at gmail)
  • seomaster

    seomaster April 11th, 2021 @ 04:22 AM

    This is important, though it's necessary to help you head over to it weblink: web link

  • seomaster

    seomaster April 14th, 2021 @ 06:40 AM

    For this web site, you will see our account, remember to go through this info. online casino

  • seomaster

    seomaster April 22nd, 2021 @ 09:52 PM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... ranking kasyn

  • seomaster

    seomaster April 23rd, 2021 @ 07:31 PM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. ranking kasyn

  • seomaster

    seomaster April 25th, 2021 @ 08:09 PM

    Make the most of mainly premium substances - you will find him or her for: casino online

  • seomaster

    seomaster April 26th, 2021 @ 07:36 PM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. casino online

  • seomaster

    seomaster April 27th, 2021 @ 07:26 PM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... casino online

  • seomaster

    seomaster April 28th, 2021 @ 01:16 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. The Best Roof Cleaners in Nanaimo

  • seomaster

    seomaster April 28th, 2021 @ 07:16 PM

    On this page you can read my interests, write something special. casino online

  • seomaster

    seomaster May 4th, 2021 @ 07:15 PM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... online casino magyaroknak

  • seomaster

    seomaster May 7th, 2021 @ 07:08 PM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. norske bettingsider

  • seomaster

    seomaster May 8th, 2021 @ 05:48 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. nye casinoer

  • seomaster

    seomaster May 8th, 2021 @ 11:30 PM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. online casino uk

  • seomaster

    seomaster May 9th, 2021 @ 11:08 PM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... visit this site

  • seomaster

    seomaster May 11th, 2021 @ 07:19 PM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... visit this site

  • seomaster

    seomaster May 15th, 2021 @ 12:17 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... Get more info

  • seomaster

    seomaster May 16th, 2021 @ 04:52 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... Get more info

  • seomaster

    seomaster May 24th, 2021 @ 06:54 AM

    I understand this column. I realize You put a many of struggle to found this story. I admire your process. casino online

  • seomaster

    seomaster May 25th, 2021 @ 07:06 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... casino online

  • seomaster

    seomaster May 25th, 2021 @ 11:20 PM

    It is very good, but look at the information at this address. casino online

  • seomaster

    seomaster May 27th, 2021 @ 06:45 AM

    It is very good, but look at the information at this address. gry hazardowe online

  • seomaster

    seomaster May 28th, 2021 @ 07:36 PM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... kasyno online

  • seomaster

    seomaster May 28th, 2021 @ 11:10 PM

    It is very good, but look at the information at this address. custom chenille patches

  • seomaster

    seomaster May 30th, 2021 @ 11:00 PM

    It is very good, but look at the information at this address. kasyno internetowe

  • seomaster

    seomaster May 31st, 2021 @ 11:05 PM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. online casino

  • seomaster

    seomaster June 1st, 2021 @ 07:56 AM

    For this web site, you will see our account, remember to go through this info. custom chenille patches

  • seomaster

    seomaster June 3rd, 2021 @ 12:27 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. casino på internet

  • seomaster

    seomaster June 4th, 2021 @ 02:02 AM

    I recommend only good and reliable information, so see it: casinobonusar

  • seomaster

    seomaster June 5th, 2021 @ 03:17 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... casino utan insättningskrav

  • seomaster

    seomaster June 6th, 2021 @ 06:34 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. online kaszinó

  • seomaster

    seomaster June 7th, 2021 @ 03:46 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... magyar online casino

  • seomaster
  • seomaster

    seomaster June 10th, 2021 @ 04:01 AM

    I recommend only good and reliable information, so see it: custom biker patches,

  • seomaster

    seomaster June 13th, 2021 @ 02:11 AM

    For this web site, you will see our account, remember to go through this info. visit this page,

  • seomaster

    seomaster June 16th, 2021 @ 05:58 AM

    I recommend only good and reliable information, so see it: custom biker patches,

  • seomaster

    seomaster June 19th, 2021 @ 02:06 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. large motorcycle patches,

  • seomaster

    seomaster June 29th, 2021 @ 11:51 AM

    Your blogs further more each else volume is so entertaining further serviceable It appoints me befall retreat encore. I will instantly grab your rss feed to stay informed of any updates. click here,

  • seomaster

    seomaster July 4th, 2021 @ 03:02 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... motorcycle vest patches

  • seomaster

    seomaster July 6th, 2021 @ 12:47 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. online casino

  • seomaster

    seomaster July 6th, 2021 @ 06:02 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... biker back patches

  • seomaster

    seomaster July 7th, 2021 @ 11:42 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... casino online

  • seomaster

    seomaster July 8th, 2021 @ 02:24 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... casino games canada

  • seomaster

    seomaster July 9th, 2021 @ 03:02 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. online keno

  • seomaster

    seomaster July 10th, 2021 @ 12:09 AM

    I invite you to the page where you can read with interesting information on similar topics. click here,

  • seomaster

    seomaster July 10th, 2021 @ 07:11 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. online casino reviews

  • seomaster

    seomaster July 11th, 2021 @ 12:07 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. best payout online casino canada

  • seomaster

    seomaster July 11th, 2021 @ 06:48 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. Superslot

  • seomaster

    seomaster July 12th, 2021 @ 11:28 PM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. odds sider

  • seomaster

    seomaster July 14th, 2021 @ 02:55 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... custom iron on patches,

  • seomaster

    seomaster July 15th, 2021 @ 03:09 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... custom name patches,

  • seomaster

    seomaster July 16th, 2021 @ 02:12 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... casinos online

  • seomaster

    seomaster July 17th, 2021 @ 11:50 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... casino online portugal

  • seomaster

    seomaster July 18th, 2021 @ 12:53 PM

    wow this saintly however ,I love your enter plus nice pics might be part personss negative love being defrent mind total poeple , bingo online

  • seomaster

    seomaster July 19th, 2021 @ 06:33 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. kasyna online

  • seomaster

    seomaster July 22nd, 2021 @ 05:36 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... custom patches no minimum,

  • seomaster

    seomaster July 23rd, 2021 @ 01:05 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. polskie kasyno online

  • seomaster

    seomaster July 24th, 2021 @ 02:40 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... black jack online

  • seomaster

    seomaster July 25th, 2021 @ 05:29 AM

    I understand this column. I realize You put a many of struggle to found this story. I admire your process. digitizing services,

  • seomaster

    seomaster July 25th, 2021 @ 05:30 AM

    I understand this column. I realize You put a many of struggle to found this story. I admire your process. digitizing services,

  • seomaster

    seomaster July 26th, 2021 @ 01:00 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... magyar online kaszinó

  • seomaster

    seomaster July 27th, 2021 @ 08:21 AM

    Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... quality punch digitizing,

  • seomaster

    seomaster July 28th, 2021 @ 02:28 AM

    So lot to occur over your amazing blog. Your blog procures me a fantastic transaction of enjoyable.. Salubrious lot beside the scene. machine embroidery digitizing service,

  • seomaster

    seomaster July 28th, 2021 @ 11:40 PM

    I can recommend primarily decent and even responsible tips, as a result view it: 먹튀폴리스 심바

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Provides common named scopes and object based searching.

People watching this ticket

Attachments

Pages