Skip to content

Commit

Permalink
Change the deprecation messages to specify that removal/changes will …
Browse files Browse the repository at this point in the history
…happen in 3.0
  • Loading branch information
jeremyevans committed Mar 27, 2009
1 parent 8feee32 commit ac1e97f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions lib/sequel/dataset.rb
Expand Up @@ -119,7 +119,7 @@ def as(aliaz)
# Returns an array with all records in the dataset. If a block is given,
# the array is iterated over after all items have been loaded.
def all(opts = (defarg=true;nil), &block)
Deprecation.deprecate("Calling Dataset#all with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).all.") unless defarg
Deprecation.deprecate("Calling Dataset#all with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).all.") unless defarg
a = []
defarg ? each{|r| a << r} : each(opts){|r| a << r}
post_load(a)
Expand Down Expand Up @@ -171,14 +171,14 @@ def def_mutation_method(*meths)
# Deletes the records in the dataset. The returned value is generally the
# number of records deleted, but that is adapter dependent.
def delete(opts=(defarg=true;nil))
Deprecation.deprecate("Calling Dataset#delete with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).delete.") unless defarg
Deprecation.deprecate("Calling Dataset#delete with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).delete.") unless defarg
execute_dui(defarg ? delete_sql : delete_sql(opts))
end

# Iterates over the records in the dataset as they are yielded from the
# database adapter, and returns self.
def each(opts = (defarg=true;nil), &block)
Deprecation.deprecate("Calling Dataset#each with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).each.") unless defarg
Deprecation.deprecate("Calling Dataset#each with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).each.") unless defarg
if opts && opts.keys.any?{|o| COLUMN_CHANGE_OPTS.include?(o)}
prev_columns = @columns
begin
Expand Down Expand Up @@ -251,7 +251,7 @@ def set_overrides(hash)
# Updates values for the dataset. The returned value is generally the
# number of rows updated, but that is adapter dependent.
def update(values={}, opts=(defarg=true;nil))
Deprecation.deprecate("Calling Dataset#update with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).update.") unless defarg
Deprecation.deprecate("Calling Dataset#update with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).update.") unless defarg
execute_dui(defarg ? update_sql(values) : update_sql(value, opts))
end

Expand Down Expand Up @@ -339,7 +339,7 @@ def post_load(all_records)
def virtual_row_block_call(block)
return unless block
unless Sequel.virtual_row_instance_eval
Deprecation.deprecate('Using a VirtualRow block without an argument is deprecated, and its meaning will change in a future version. Add a block argument to keep the old semantics, or set Sequel.virtual_row_instance_eval = true to use instance_eval for VirtualRow blocks without arguments.') unless block.arity == 1
Deprecation.deprecate('Using a VirtualRow block without an argument is deprecated, and its meaning will change in Sequel 3.0. Add a block argument to keep the old semantics, or set Sequel.virtual_row_instance_eval = true to use instance_eval for VirtualRow blocks without arguments.') unless block.arity == 1
return block.call(SQL::VirtualRow.new)
end
case block.arity
Expand Down
10 changes: 5 additions & 5 deletions lib/sequel/dataset/convenience.rb
Expand Up @@ -7,8 +7,8 @@ class Dataset
#
# ds[:id=>1] => {:id=1}
def [](*conditions)
Deprecation.deprecate('Using an Integer argument to Dataset#[] is deprecated and will raise an error in a future version. Use Dataset#first.') if conditions.length == 1 and conditions.is_a?(Integer)
Deprecation.deprecate('Using Dataset#[] without an argument is deprecated and will raise an error in a future version. Use Dataset#first.') if conditions.length == 0
Deprecation.deprecate('Using an Integer argument to Dataset#[] is deprecated and will raise an error in Sequel 3.0. Use Dataset#first.') if conditions.length == 1 and conditions.is_a?(Integer)
Deprecation.deprecate('Using Dataset#[] without an argument is deprecated and will raise an error in Sequel 3.0. Use Dataset#first.') if conditions.length == 0
first(*conditions)
end

Expand Down Expand Up @@ -155,7 +155,7 @@ def last(*args, &block)
# ds.map(:id) => [1, 2, 3, ...]
# ds.map{|r| r[:id] * 2} => [2, 4, 6, ...]
def map(column=nil, &block)
Deprecation.deprecate('Using Dataset#map with an argument and a block is deprecated and will raise an error in a future version. Use an argument or a block, not both.') if column && block
Deprecation.deprecate('Using Dataset#map with an argument and a block is deprecated and will raise an error in Sequel 3.0. Use an argument or a block, not both.') if column && block
if column
super(){|r| r[column]}
else
Expand Down Expand Up @@ -211,7 +211,7 @@ def range(column)

# Returns the first record in the dataset.
def single_record(opts = (defarg=true;nil))
Deprecation.deprecate("Calling Dataset#single_record with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).single_record.") unless defarg
Deprecation.deprecate("Calling Dataset#single_record with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).single_record.") unless defarg
ds = clone(:limit=>1)
opts = opts.merge(:limit=>1) if opts and opts[:limit]
defarg ? ds.each{|r| return r} : ds.each(opts){|r| return r}
Expand All @@ -221,7 +221,7 @@ def single_record(opts = (defarg=true;nil))
# Returns the first value of the first record in the dataset.
# Returns nil if dataset is empty.
def single_value(opts = (defarg=true;nil))
Deprecation.deprecate("Calling Dataset#single_value with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).single_value.") unless defarg
Deprecation.deprecate("Calling Dataset#single_value with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).single_value.") unless defarg
ds = naked.clone(:graph=>false)
if r = (defarg ? ds.single_record : ds.single_record(opts))
r.values.first
Expand Down
10 changes: 5 additions & 5 deletions lib/sequel/dataset/sql.rb
Expand Up @@ -88,7 +88,7 @@ def count
# dataset.filter{|o| o.price >= 100}.delete_sql #=>
# "DELETE FROM items WHERE (price >= 100)"
def delete_sql(opts = (defarg=true;nil))
Deprecation.deprecate("Calling Dataset#delete_sql with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).delete_sql.") unless defarg
Deprecation.deprecate("Calling Dataset#delete_sql with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).delete_sql.") unless defarg
opts = opts ? @opts.merge(opts) : @opts

return static_sql(opts[:sql]) if opts[:sql]
Expand Down Expand Up @@ -148,7 +148,7 @@ def exclude(*cond, &block)
# DB.select(1).where(DB[:items].exists).sql
# #=> "SELECT 1 WHERE EXISTS (SELECT * FROM items)"
def exists(opts = (defarg=true;nil))
Deprecation.deprecate("Calling Dataset#exists with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).exists.") unless defarg
Deprecation.deprecate("Calling Dataset#exists with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).exists.") unless defarg
LiteralString.new("EXISTS (#{defarg ? select_sql : select_sql(opts)})")
end

Expand Down Expand Up @@ -684,7 +684,7 @@ def select_more(*columns, &block)
#
# dataset.select_sql # => "SELECT * FROM items"
def select_sql(opts = (defarg=true;nil))
Deprecation.deprecate("Calling Dataset#select_sql with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).select_sql.") unless defarg
Deprecation.deprecate("Calling Dataset#select_sql with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).select_sql.") unless defarg
opts = opts ? @opts.merge(opts) : @opts
return static_sql(opts[:sql]) if opts[:sql]
sql = 'SELECT'
Expand All @@ -694,7 +694,7 @@ def select_sql(opts = (defarg=true;nil))

# Same as select_sql, not aliased directly to make subclassing simpler.
def sql(opts = (defarg=true;nil))
Deprecation.deprecate("Calling Dataset#select_sql with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).select_sql.") unless defarg
Deprecation.deprecate("Calling Dataset#select_sql with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).select_sql.") unless defarg
defarg ? select_sql : select_sql(opts)
end

Expand Down Expand Up @@ -734,7 +734,7 @@ def unordered
# Raises an error if the dataset is grouped or includes more
# than one table.
def update_sql(values = {}, opts = (defarg=true;nil))
Deprecation.deprecate("Calling Dataset#update_sql with an argument is deprecated and will raise an error in a future version. Use dataset.clone(opts).update_sql.") unless defarg
Deprecation.deprecate("Calling Dataset#update_sql with an argument is deprecated and will raise an error in Sequel 3.0. Use dataset.clone(opts).update_sql.") unless defarg
opts = opts ? @opts.merge(opts) : @opts

return static_sql(opts[:sql]) if opts[:sql]
Expand Down
2 changes: 1 addition & 1 deletion lib/sequel/deprecated.rb
Expand Up @@ -23,7 +23,7 @@ module Deprecation

# Print the message to the output stream
def self.deprecate(method, instead=nil)
message = instead ? "#{method} is deprecated and will be removed in a future version. #{instead}." : method
message = instead ? "#{method} is deprecated and will be removed in Sequel 3.0. #{instead}." : method
return unless output
output.puts(message)
case backtraces
Expand Down

0 comments on commit ac1e97f

Please sign in to comment.