[Rails-core] delete_all with limit

2014-04-03 Thread Isha


Hi,

I was wondering if there is a specific reason why delete_all does not 
accept limits? Ultimately, I want to achieve batched deletes in my 
application and something like delete_in_batches or even delete_allthat 
accepts limits would be useful.

I can try adding this but wanted to get some feedback/suggestions first.

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] delete_all with limit

2014-04-03 Thread Matt Jones

On Apr 3, 2014, at 2:28 PM, Isha i...@jadedpixel.com wrote:

 Hi,
 
 I was wondering if there is a specific reason why delete_all does not accept 
 limits? Ultimately, I want to achieve batched deletes in my application and 
 something like delete_in_batches or even delete_allthat accepts limits would 
 be useful.
 
 I can try adding this but wanted to get some feedback/suggestions first.

FWIW, passing a LIMIT clause to a DELETE is included in the SQL92 standard, but 
actually-implemented support is spotty:

* Postgres: not supported
* Oracle: not supported (but maybe hackable with ROWNUM tricks)
* SQLite3: supported if enabled at compile time
* MySQL: supported
* SQL Server: not supported (but maybe with a TOP subquery?)

—Matt Jones


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [Rails-core] delete_all with limit

2014-04-03 Thread Mohamed Wael Khobalatte
In addition to Matt's suggestion, there is a usual workaround for this
that's achieved by copying all ids in batches to a separate table then
joining on it. I guess it's tricky to achieve with Rails given this table
dependency. How would you solve it if it proves needed?


On Thu, Apr 3, 2014 at 11:54 PM, Matt Jones al2o...@gmail.com wrote:


 On Apr 3, 2014, at 2:28 PM, Isha i...@jadedpixel.com wrote:

 Hi,

 I was wondering if there is a specific reason why delete_all does not
 accept limits? Ultimately, I want to achieve batched deletes in my
 application and something like delete_in_batches or even delete_allthat
 accepts limits would be useful.

 I can try adding this but wanted to get some feedback/suggestions first.


 FWIW, passing a LIMIT clause to a DELETE is included in the SQL92
 standard, but actually-implemented support is spotty:

 * Postgres: not supported
 * Oracle: not supported (but maybe hackable with ROWNUM tricks)
 * SQLite3: supported if enabled at compile time
 * MySQL: supported
 * SQL Server: not supported (but maybe with a TOP subquery?)

 --Matt Jones




-- 
Mohamed Wael Khobalatte

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.