On Tuesday, February 5, 2013 7:53:44 AM UTC-8, Gergely Pál - night[w] wrote:
>
> Hello! 
>
> I have a replicated MySQL server which gives a warning every time when 
> an UPDATE query has a LIMIT keyword. This is not a good thing, I know, 
> but I need a workaround. 
>
> When I query for a Sequel Model instance like this: 
> foo = Foo.where(:boolean_attribute => true).order(:date_attribute).first 
>
> Sequel makes this SQL query (which is a correct one of course): 
> SELECT * FROM `foo` WHERE (`boolean_attribute` IS TRUE) ORDER BY 
> `date_attribute` LIMIT 1 
>
> After doing some modifications on the foo instance, then I do 
> foo.save_changes and Sequel makes this query: 
> UPDATE `foo` SET `some_attribute` = 'value' WHERE (`foo_id` = 18) LIMIT 1 
>
> And that's where I want the 'LIMIT 1' to disappear. foo_id is the 
> primary key of the table, Sequel does know this too, so the LIMIT 1 is 
> unnecessary, because there can be only one row in the table with foo_id 
> 18. 
>
> Is there a way to do this? 
>
>
The best way is probably this:

  class Sequel::Model
      private
      def _update_dataset
        super.unlimited
      end
  end

You aren't the first person to request this, so I probably should add a 
plugin that does this.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to