Skip to content

Commit 94a8d55

Browse files
committed
fix: clean robucop errors after remove_enum_value
1 parent f9a9537 commit 94a8d55

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/active_record/postgres_enum/postgresql_adapter.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ def add_enum_value(name, value, after: nil, before: nil)
6464
end
6565
execute sql
6666
end
67-
67+
6868
def remove_enum_value(name, value)
69-
sql = "DELETE FROM pg_enum WHERE enumlabel=#{quote value} AND enumtypid=(SELECT oid FROM pg_type WHERE typname='#{name}')"
69+
sql = %{
70+
DELETE FROM pg_enum
71+
WHERE enumlabel=#{quote value}
72+
AND enumtypid=(SELECT oid FROM pg_type WHERE typname='#{name}')
73+
}
7074
execute sql
7175
end
7276

spec/active_record/postgres_enum_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,25 @@
7373
it "removes an enum value with a space" do
7474
expect { connection.add_enum_value(:foo, "a 3") }.to_not raise_error
7575
expect { connection.remove_enum_value(:foo, "a 3") }.to_not raise_error
76-
expect(connection.enums[:foo]).to eq ["a1", "a2"]
76+
expect(connection.enums[:foo]).to eq %w(a1 a2)
7777
end
7878

7979
it "removes an enum value with a comma" do
8080
expect { connection.add_enum_value(:foo, "a,3") }.to_not raise_error
8181
expect { connection.remove_enum_value(:foo, "a,3") }.to_not raise_error
82-
expect(connection.enums[:foo]).to eq ["a1", "a2"]
82+
expect(connection.enums[:foo]).to eq %w(a1 a2)
8383
end
8484

8585
it "removes an enum value with a single quote" do
8686
expect { connection.add_enum_value(:foo, "a'3") }.to_not raise_error
8787
expect { connection.remove_enum_value(:foo, "a'3") }.to_not raise_error
88-
expect(connection.enums[:foo]).to eq ["a1", "a2"]
88+
expect(connection.enums[:foo]).to eq %w(a1 a2)
8989
end
9090

9191
it "removes an enum value with a double quote" do
9292
expect { connection.add_enum_value(:foo, "a\"3") }.to_not raise_error
9393
expect { connection.remove_enum_value(:foo, "a\"3") }.to_not raise_error
94-
expect(connection.enums[:foo]).to eq ["a1", "a2"]
94+
expect(connection.enums[:foo]).to eq %w(a1 a2)
9595
end
9696

9797
it "renames an enum value" do

0 commit comments

Comments
 (0)