Skip to content

Commit

Permalink
Added support for order and limit in DELETE statement in MySQL adapter (
Browse files Browse the repository at this point in the history
  • Loading branch information
noteflakes committed Feb 16, 2008
1 parent 70cf521 commit 0a1122f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sequel_core/CHANGELOG
@@ -1,5 +1,7 @@
=== SVN

* Added support for order and limit in DELETE statement in MySQL adapter (#160).

* Added checks to Dataset#multi_insert to prevent work if no values are given (#162).

* Override ruby2ruby implementation of Proc#to_sexp which leaks memory (#161).
Expand Down
15 changes: 14 additions & 1 deletion sequel_core/lib/sequel_core/adapters/mysql.rb
Expand Up @@ -316,13 +316,26 @@ def having(*cond, &block)
# MySQL supports ORDER and LIMIT clauses in UPDATE statements.
def update_sql(values, opts = nil)
sql = super

opts = opts ? @opts.merge(opts) : @opts

if order = opts[:order]
sql << " ORDER BY #{column_list(order)}"
end
if limit = opts[:limit]
sql << " LIMIT #{limit}"
end

sql
end

# MySQL supports ORDER and LIMIT clauses in DELETE statements.
def delete_sql(opts = nil)
sql = super
opts = opts ? @opts.merge(opts) : @opts

if order = opts[:order]
sql << " ORDER BY #{column_list(order)}"
end
if limit = opts[:limit]
sql << " LIMIT #{limit}"
end
Expand Down

0 comments on commit 0a1122f

Please sign in to comment.