Skip to content

Commit 17ebb36

Browse files
committed
standardrb
1 parent 9d07027 commit 17ebb36

File tree

8 files changed

+47
-60
lines changed

8 files changed

+47
-60
lines changed

lib/active_record/connection_adapters/sqlserver/core_ext/attribute_methods.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def attributes_for_update(attribute_names)
1515

1616
super(attribute_names).reject do |name|
1717
column = self.class.columns_hash[name]
18-
column && column.respond_to?(:is_identity?) && column.is_identity?
18+
column&.respond_to?(:is_identity?) && column.is_identity?
1919
end
2020
end
2121
end

lib/active_record/connection_adapters/sqlserver/sql_type_metadata.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ def ==(other)
2929
alias_method :eql?, :==
3030

3131
def hash
32-
TypeMetadata.hash ^
33-
__getobj__.hash ^
34-
is_identity.hash ^
35-
is_primary.hash ^
36-
table_name.hash ^
37-
ordinal_position.hash
32+
[TypeMetadata, __getobj__, is_identity, is_primary, table_name, ordinal_position].hash
3833
end
3934

4035
private

lib/active_record/connection_adapters/sqlserver/type/date.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ def sqlserver_type
99
"date"
1010
end
1111

12-
def serialize(value)
12+
def serialize(_value)
1313
value = super
1414
return value unless value.acts_like?(:date)
1515

1616
date = super.to_formatted_s(:_sqlserver_dateformat)
17-
Data.new date, self
17+
Data.new(date, self)
1818
end
1919

2020
def deserialize(value)

lib/active_record/connection_adapters/sqlserver/type/datetime.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ def sqlserver_type
1111
"datetime"
1212
end
1313

14-
def serialize(value)
14+
def serialize(_value)
1515
value = super
1616
return value unless value.acts_like?(:time)
1717

1818
datetime = "#{value.to_formatted_s(:_sqlserver_datetime)}.#{quote_fractional(value)}"
19-
20-
Data.new datetime, self
19+
Data.new(datetime, self)
2120
end
2221

2322
def deserialize(value)

lib/active_record/connection_adapters/sqlserver_column.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,7 @@ def ==(other)
5858
alias_method :eql?, :==
5959

6060
def hash
61-
Column.hash ^
62-
super.hash ^
63-
is_identity?.hash ^
64-
is_primary?.hash ^
65-
table_name.hash ^
66-
ordinal_position.hash
61+
[Column, super, is_identity?, is_primary?, table_name, ordinal_position].hash
6762
end
6863

6964
private

test/cases/column_test_sqlserver.rb

+34-36
Large diffs are not rendered by default.

test/cases/migration_test_sqlserver.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class MigrationTestSQLServer < ActiveRecord::TestCase
4545

4646
it "not drop the default constraint if just renaming" do
4747
find_default = lambda do
48-
connection.execute_procedure(:sp_helpconstraint, "sst_string_defaults", "nomsg").select do |row|
48+
connection.execute_procedure(:sp_helpconstraint, "sst_string_defaults", "nomsg").reverse.find do |row|
4949
row["constraint_type"] == "DEFAULT on column string_with_pretend_paren_three"
50-
end.last
50+
end
5151
end
5252
default_before = find_default.call
5353
connection.change_column :sst_string_defaults, :string_with_pretend_paren_three, :string, limit: 255

test/support/coerceable_test_sqlserver.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ def coerce_tests!(*methods)
2020

2121
def coerce_all_tests!
2222
instance_methods(false).each do |method|
23-
next unless /\Atest/.match?(method.to_s)
23+
next unless method.to_s.start_with?("test")
2424

2525
undef_method(method)
2626
end
27-
STDOUT.puts "🙉 🙈 🙊 Undefined all tests: #{name}"
27+
$stdout.puts "🙉 🙈 🙊 Undefined all tests: #{name}"
2828
end
2929

3030
private
@@ -43,9 +43,9 @@ def coerced_test_warning(test_to_coerce)
4343
end
4444

4545
if result.blank?
46-
STDOUT.puts "🐳 Unfound coerced test: #{name}##{m}"
46+
$stdout.puts "🐳 Unfound coerced test: #{name}##{m}"
4747
else
48-
STDOUT.puts "🐵 Undefined coerced test: #{name}##{m}"
48+
$stdout.puts "🐵 Undefined coerced test: #{name}##{m}"
4949
end
5050
end
5151
end

0 commit comments

Comments
 (0)