Skip to content

Commit 8480e4c

Browse files
authored
Merge pull request #830 from rails-sqlserver/rubocop-Indentation
Rubocop: Enable Layout/IndentationWidth and Layout/TrailingWhitespace cops
2 parents 537ca08 + 9905c4a commit 8480e4c

File tree

7 files changed

+38
-38
lines changed

7 files changed

+38
-38
lines changed

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def change_column(table_name, column_name, type, options = {})
143143
column_object = schema_cache.columns(table_name).find { |c| c.name.to_s == column_name.to_s }
144144
without_constraints = options.key?(:default) || options.key?(:limit)
145145
default = if !options.key?(:default) && column_object
146-
column_object.default
146+
column_object.default
147147
else
148148
options[:default]
149149
end
@@ -415,8 +415,8 @@ def column_definitions(table_name)
415415

416416
def column_definitions_sql(database, identifier)
417417
object_name = prepared_statements ? "@0" : quote(identifier.object)
418-
schema_name = if identifier.schema.blank?
419-
"schema_name()"
418+
schema_name = if identifier.schema.blank?
419+
"schema_name()"
420420
else
421421
prepared_statements ? "@1" : quote(identifier.schema)
422422
end
@@ -506,7 +506,7 @@ def remove_indexes(table_name, column_name)
506506

507507
def get_table_name(sql)
508508
tn = if sql =~ /^\s*(INSERT|EXEC sp_executesql N'INSERT)(\s+INTO)?\s+([^\(\s]+)\s*|^\s*update\s+([^\(\s]+)\s*/i
509-
Regexp.last_match[3] || Regexp.last_match[4]
509+
Regexp.last_match[3] || Regexp.last_match[4]
510510
elsif sql =~ /FROM\s+([^\(\s]+)\s*/i
511511
Regexp.last_match[1]
512512
else

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def sqlserver_type
1414
def serialize(value)
1515
value = super
1616
return value unless value.acts_like?(:time)
17-
17+
1818
datetime = "#{value.to_s(:_sqlserver_datetime)}.#{quote_fractional(value)}"
1919

2020
Data.new datetime, self

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def serialize(value)
1212
return value unless value.acts_like?(:time)
1313

1414
time = "#{value.to_s(:_sqlserver_time)}.#{quote_fractional(value)}"
15-
15+
1616
Data.new time, self
1717
end
1818

test/cases/json_test_sqlserver.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
require "cases/helper_sqlserver"
44

55
if ActiveRecord::Base.connection.supports_json?
6-
class JsonTestSQLServer < ActiveRecord::TestCase
7-
before do
8-
@o1 = SSTestDatatypeMigrationJson.create! json_col: { "a" => "a", "b" => "b", "c" => "c" }
9-
@o2 = SSTestDatatypeMigrationJson.create! json_col: { "a" => nil, "b" => "b", "c" => "c" }
10-
@o3 = SSTestDatatypeMigrationJson.create! json_col: { "x" => 1, "y" => 2, "z" => 3 }
11-
@o4 = SSTestDatatypeMigrationJson.create! json_col: { "array" => [1, 2, 3] }
12-
@o5 = SSTestDatatypeMigrationJson.create! json_col: nil
13-
end
6+
class JsonTestSQLServer < ActiveRecord::TestCase
7+
before do
8+
@o1 = SSTestDatatypeMigrationJson.create! json_col: { "a" => "a", "b" => "b", "c" => "c" }
9+
@o2 = SSTestDatatypeMigrationJson.create! json_col: { "a" => nil, "b" => "b", "c" => "c" }
10+
@o3 = SSTestDatatypeMigrationJson.create! json_col: { "x" => 1, "y" => 2, "z" => 3 }
11+
@o4 = SSTestDatatypeMigrationJson.create! json_col: { "array" => [1, 2, 3] }
12+
@o5 = SSTestDatatypeMigrationJson.create! json_col: nil
13+
end
1414

15-
it "can return and save JSON data" do
16-
_(SSTestDatatypeMigrationJson.find(@o1.id).json_col).must_equal({ "a" => "a", "b" => "b", "c" => "c" })
17-
@o1.json_col = { "a" => "a" }
18-
_(@o1.json_col).must_equal({ "a" => "a" })
19-
@o1.save!
20-
_(@o1.reload.json_col).must_equal({ "a" => "a" })
21-
end
15+
it "can return and save JSON data" do
16+
_(SSTestDatatypeMigrationJson.find(@o1.id).json_col).must_equal({ "a" => "a", "b" => "b", "c" => "c" })
17+
@o1.json_col = { "a" => "a" }
18+
_(@o1.json_col).must_equal({ "a" => "a" })
19+
@o1.save!
20+
_(@o1.reload.json_col).must_equal({ "a" => "a" })
21+
end
2222

23-
it "can use ISJSON function" do
24-
_(SSTestDatatypeMigrationJson.where("ISJSON(json_col) > 0").count).must_equal 4
25-
_(SSTestDatatypeMigrationJson.where("ISJSON(json_col) IS NULL").count).must_equal 1
26-
end
23+
it "can use ISJSON function" do
24+
_(SSTestDatatypeMigrationJson.where("ISJSON(json_col) > 0").count).must_equal 4
25+
_(SSTestDatatypeMigrationJson.where("ISJSON(json_col) IS NULL").count).must_equal 1
26+
end
2727

28-
it "can use JSON_VALUE function" do
29-
_(SSTestDatatypeMigrationJson.where("JSON_VALUE(json_col, '$.b') = 'b'").count).must_equal 2
28+
it "can use JSON_VALUE function" do
29+
_(SSTestDatatypeMigrationJson.where("JSON_VALUE(json_col, '$.b') = 'b'").count).must_equal 2
30+
end
3031
end
3132
end
32-
end

test/cases/migration_test_sqlserver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ class MigrationTestSQLServer < ActiveRecord::TestCase
5555
assert default_after
5656
assert_equal default_before["constraint_keys"], default_after["constraint_keys"]
5757
end
58-
58+
5959
it "change limit" do
6060
assert_nothing_raised { connection.change_column :people, :lock_version, :integer, limit: 8 }
6161
end
62-
62+
6363
it "change null and default" do
6464
assert_nothing_raised { connection.change_column :people, :first_name, :text, null: true, default: nil }
6565
end

test/cases/pessimistic_locking_test_sqlserver.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class PessimisticLockingTestSQLServer < ActiveRecord::TestCase
3838
end
3939

4040
it "lock with eager find" do
41-
assert_nothing_raised do
42-
Person.transaction do
43-
person = Person.lock(true).includes(:readers).find(1)
44-
_(person).must_equal Person.find(1)
45-
end
46-
end
41+
assert_nothing_raised do
42+
Person.transaction do
43+
person = Person.lock(true).includes(:readers).find(1)
44+
_(person).must_equal Person.find(1)
45+
end
46+
end
4747
end
4848

4949
it "can add a custom lock directive" do

test/cases/schema_dumper_test_sqlserver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ class SchemaDumperTestSQLServer < ActiveRecord::TestCase
2727
assert_line :date, type: "date", limit: nil, precision: nil, scale: nil, default: "01-01-0001"
2828
assert_line :datetime, type: "datetime", limit: nil, precision: nil, scale: nil, default: "01-01-1753 00:00:00.123"
2929
if connection_dblib_73?
30-
assert_line :datetime2_7, type: "datetime", limit: nil, precision: 7, scale: nil, default: "12-31-9999 23:59:59.9999999"
30+
assert_line :datetime2_7, type: "datetime", limit: nil, precision: 7, scale: nil, default: "12-31-9999 23:59:59.9999999"
3131
assert_line :datetime2_3, type: "datetime", limit: nil, precision: 3, scale: nil, default: nil
3232
assert_line :datetime2_1, type: "datetime", limit: nil, precision: 1, scale: nil, default: nil
3333
end
3434
assert_line :smalldatetime, type: "smalldatetime",limit: nil, precision: nil, scale: nil, default: "01-01-1901 15:45:00.0"
3535
if connection_dblib_73?
36-
assert_line :time_7, type: "time", limit: nil, precision: 7, scale: nil, default: "04:20:00.2883215"
36+
assert_line :time_7, type: "time", limit: nil, precision: 7, scale: nil, default: "04:20:00.2883215"
3737
assert_line :time_2, type: "time", limit: nil, precision: 2, scale: nil, default: nil
3838
assert_line :time_default, type: "time", limit: nil, precision: 7, scale: nil, default: "15:03:42.0621978"
3939
end

0 commit comments

Comments
 (0)