Skip to content

Commit 9869a5d

Browse files
committed
dev: formatted deprecation warnings onto one line each
and hushed warnings when running the test suite.
1 parent 77ba7f1 commit 9869a5d

File tree

7 files changed

+26
-38
lines changed

7 files changed

+26
-38
lines changed

lib/sqlite3/database.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ def initialize file, options = {}, zvfs = nil
116116

117117
def type_translation= value # :nodoc:
118118
warn(<<-eowarn) if $VERBOSE
119-
#{caller[0]} is calling SQLite3::Database#type_translation=
120-
SQLite3::Database#type_translation= is deprecated and will be removed
121-
in version 2.0.0.
119+
#{caller[0]} is calling `SQLite3::Database#type_translation=` which is deprecated and will be removed in version 2.0.0.
122120
eowarn
123121
@type_translator = make_type_translator value
124122
@type_translation = value
@@ -189,9 +187,7 @@ def execute sql, bind_vars = [], *args, &block
189187
end
190188

191189
warn(<<-eowarn) if $VERBOSE
192-
#{caller[0]} is calling SQLite3::Database#execute with nil or multiple bind params
193-
without using an array. Please switch to passing bind parameters as an array.
194-
Support for bind parameters as *args will be removed in 2.0.0.
190+
#{caller[0]} is calling `SQLite3::Database#execute` with nil or multiple bind params without using an array. Please switch to passing bind parameters as an array. Support for bind parameters as *args will be removed in 2.0.0.
195191
eowarn
196192
end
197193

@@ -248,9 +244,7 @@ def execute_batch( sql, bind_vars = [], *args )
248244
unless [Array, Hash].include?(bind_vars.class)
249245
bind_vars = [bind_vars]
250246
warn(<<-eowarn) if $VERBOSE
251-
#{caller[0]} is calling SQLite3::Database#execute_batch with bind parameters
252-
that are not a list of a hash. Please switch to passing bind parameters as an
253-
array or hash. Support for this behavior will be removed in version 2.0.0.
247+
#{caller[0]} is calling `SQLite3::Database#execute_batch` with bind parameters that are not a list of a hash. Please switch to passing bind parameters as an array or hash. Support for this behavior will be removed in version 2.0.0.
254248
eowarn
255249
end
256250

@@ -263,9 +257,7 @@ def execute_batch( sql, bind_vars = [], *args )
263257
end
264258

265259
warn(<<-eowarn) if $VERBOSE
266-
#{caller[0]} is calling SQLite3::Database#execute_batch with nil or multiple bind params
267-
without using an array. Please switch to passing bind parameters as an array.
268-
Support for this behavior will be removed in version 2.0.0.
260+
#{caller[0]} is calling `SQLite3::Database#execute_batch` with nil or multiple bind params without using an array. Please switch to passing bind parameters as an array. Support for this behavior will be removed in version 2.0.0.
269261
eowarn
270262
end
271263

@@ -332,9 +324,7 @@ def query( sql, bind_vars = [], *args )
332324
end
333325

334326
warn(<<-eowarn) if $VERBOSE
335-
#{caller[0]} is calling SQLite3::Database#query with nil or multiple bind params
336-
without using an array. Please switch to passing bind parameters as an array.
337-
Support for this will be removed in version 2.0.0.
327+
#{caller[0]} is calling `SQLite3::Database#query` with nil or multiple bind params without using an array. Please switch to passing bind parameters as an array. Support for this will be removed in version 2.0.0.
338328
eowarn
339329
end
340330

lib/sqlite3/resultset.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,14 @@ class ArrayWithTypesAndFields < Array # :nodoc:
2020

2121
def types
2222
warn(<<-eowarn) if $VERBOSE
23-
#{caller[0]} is calling #{self.class}#types. This method will be removed in
24-
sqlite3 version 2.0.0, please call the `types` method on the SQLite3::ResultSet
25-
object that created this object
23+
#{caller[0]} is calling `#{self.class}#types` which is deprecated and will be removed in sqlite3 version 2.0.0. Please call the `types` method on the SQLite3::ResultSet object that created this object.
2624
eowarn
2725
@types
2826
end
2927

3028
def fields
3129
warn(<<-eowarn) if $VERBOSE
32-
#{caller[0]} is calling #{self.class}#fields. This method will be removed in
33-
sqlite3 version 2.0.0, please call the `columns` method on the SQLite3::ResultSet
34-
object that created this object
30+
#{caller[0]} is calling `#{self.class}#fields` which is deprecated and will be removed in sqlite3 version 2.0.0. Please call the `columns` method on the SQLite3::ResultSet object that created this object.
3531
eowarn
3632
@fields
3733
end
@@ -45,18 +41,14 @@ class HashWithTypesAndFields < Hash # :nodoc:
4541

4642
def types
4743
warn(<<-eowarn) if $VERBOSE
48-
#{caller[0]} is calling #{self.class}#types. This method will be removed in
49-
sqlite3 version 2.0.0, please call the `types` method on the SQLite3::ResultSet
50-
object that created this object
44+
#{caller[0]} is calling `#{self.class}#types` which is deprecated and will be removed in sqlite3 version 2.0.0. Please call the `types` method on the SQLite3::ResultSet object that created this object.
5145
eowarn
5246
@types
5347
end
5448

5549
def fields
5650
warn(<<-eowarn) if $VERBOSE
57-
#{caller[0]} is calling #{self.class}#fields. This method will be removed in
58-
sqlite3 version 2.0.0, please call the `columns` method on the SQLite3::ResultSet
59-
object that created this object
51+
#{caller[0]} is calling `#{self.class}#fields` which is deprecated and will be removed in sqlite3 version 2.0.0. Please call the `columns` method on the SQLite3::ResultSet object that created this object.
6052
eowarn
6153
@fields
6254
end

lib/sqlite3/translator.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ def initialize
3636
# The block should return the translated value.
3737
def add_translator( type, &block ) # :yields: type, value
3838
warn(<<-eowarn) if $VERBOSE
39-
#{caller[0]} is calling `add_translator`.
40-
Built in translators are deprecated and will be removed in version 2.0.0
39+
#{caller[0]} is calling `SQLite3::Translator#add_translator`. Built-in translators are deprecated and will be removed in version 2.0.0.
4140
eowarn
4241
@translators[ type_name( type ) ] = block
4342
end

lib/sqlite3/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module VersionProxy
1616
def self.const_missing(name)
1717
return super unless name == :Version
1818
warn(<<-eowarn) if $VERBOSE
19-
#{caller[0]}: SQLite::Version will be removed in sqlite3-ruby version 2.0.0
19+
#{caller[0]}: `SQLite::Version` will be removed in sqlite3-ruby version 2.0.0
2020
eowarn
2121
VersionProxy
2222
end

test/test_database.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,20 @@ def test_get_first_row
101101

102102
def test_get_first_row_with_type_translation_and_hash_results
103103
@db.results_as_hash = true
104-
@db.type_translation = true
105-
assert_equal({"1"=>1}, @db.get_first_row('SELECT 1'))
104+
capture_io do # hush translation deprecation warnings
105+
@db.type_translation = true
106+
assert_equal({"1"=>1}, @db.get_first_row('SELECT 1'))
107+
end
106108
end
107109

108110
def test_execute_with_type_translation_and_hash
109-
@db.results_as_hash = true
110-
@db.type_translation = true
111111
rows = []
112-
@db.execute('SELECT 1') { |row| rows << row }
112+
@db.results_as_hash = true
113+
114+
capture_io do # hush translation deprecation warnings
115+
@db.type_translation = true
116+
@db.execute('SELECT 1') { |row| rows << row }
117+
end
113118

114119
assert_equal({"1"=>1}, rows.first)
115120
end

test/test_integration_resultset.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def test_next_results_as_hash
101101
hash = @result.next
102102
assert_equal( { "a" => 1, "b" => "foo" },
103103
hash )
104-
assert_equal hash[0], 1
105-
assert_equal hash[1], "foo"
104+
assert_equal hash[@result.columns[0]], 1
105+
assert_equal hash[@result.columns[1]], "foo"
106106
end
107107

108108
def test_each

test/test_statement.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ def test_bind_blob
140140
stmt.close
141141

142142
assert_equal ['hello'], row.first
143-
assert_equal ['blob'], row.first.types
143+
capture_io do # hush deprecation warning
144+
assert_equal ['blob'], row.first.types
145+
end
144146
end
145147

146148
def test_bind_64

0 commit comments

Comments
 (0)