Skip to content

Commit

Permalink
Rubocop tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydwatkin committed Apr 29, 2024
1 parent 78b3aa3 commit ae01b55
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
10 changes: 5 additions & 5 deletions lib/active_record/connection_adapters/janus_mysql2_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def execute(sql)
case where_to_send?(sql)
when :all
send_to_replica(sql, connection: :all, method: :execute)
return super(sql)
super(sql)
when :replica
return send_to_replica(sql, connection: :replica, method: :execute)
send_to_replica(sql, connection: :replica, method: :execute)
else
Janus::Context.stick_to_primary if write_query?(sql)
Janus::Context.used_connection(:primary)
Expand All @@ -79,13 +79,13 @@ def execute_and_free(sql, name = nil, async: false)
case where_to_send?(sql)
when :all
send_to_replica(sql, connection: :all, method: :execute)
return super(sql, name, async:)
super(sql, name, async:)
when :replica
return send_to_replica(sql, connection: :replica, method: :execute)
send_to_replica(sql, connection: :replica, method: :execute)
else
Janus::Context.stick_to_primary if write_query?(sql)
Janus::Context.used_connection(:primary)
return super(sql, name, async:)
super(sql, name, async:)
end
end

Expand Down
14 changes: 7 additions & 7 deletions lib/active_record/connection_adapters/janus_trilogy_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def raw_execute(sql, name, async: false, allow_retry: false, materialize_transac
case where_to_send?(sql)
when :all
send_to_replica(sql, connection: :all, method: :execute)
return super
super
when :replica
return send_to_replica(sql, connection: :replica, method: :execute)
send_to_replica(sql, connection: :replica, method: :execute)
else
Janus::Context.stick_to_primary if write_query?(sql)
Janus::Context.used_connection(:primary)
Expand All @@ -65,9 +65,9 @@ def execute(sql)
case where_to_send?(sql)
when :all
send_to_replica(sql, connection: :all, method: :execute)
return super(sql)
super(sql)
when :replica
return send_to_replica(sql, connection: :replica, method: :execute)
send_to_replica(sql, connection: :replica, method: :execute)
else
Janus::Context.stick_to_primary if write_query?(sql)
Janus::Context.used_connection(:primary)
Expand All @@ -79,13 +79,13 @@ def execute_and_free(sql, name = nil, async: false)
case where_to_send?(sql)
when :all
send_to_replica(sql, connection: :all, method: :execute)
return super(sql, name, async:)
super(sql, name, async:)
when :replica
return send_to_replica(sql, connection: :replica, method: :execute)
send_to_replica(sql, connection: :replica, method: :execute)
else
Janus::Context.stick_to_primary if write_query?(sql)
Janus::Context.used_connection(:primary)
return super(sql, name, async:)
super(sql, name, async:)
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/janus/client.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Janus
class Client
FOUND_ROWS = 2
Expand Down
1 change: 1 addition & 0 deletions lib/janus/query_director.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Janus
class QueryDirector
ALL = :all
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/janus/query_director_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

RSpec.describe Janus::QueryDirector do
describe 'Constants' do
Expand Down Expand Up @@ -26,7 +27,7 @@
before(:each) do
Janus::Context.release_all
end

context 'when should send to all' do
it 'returns :all' do
sql = 'SET foo = bar'
Expand Down
3 changes: 2 additions & 1 deletion spec/shared_examples/a_mysql_like_server.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
RSpec.shared_examples 'a mysql like server' do
let(:create_test_table) { ActiveRecord::Base.connection.execute("CREATE TABLE `#{table_name}` (id INT);") }

Expand All @@ -12,7 +13,7 @@
FROM information_schema.tables
WHERE table_schema = '#{database}';
SQL
).to_a.map { |row| ActiveRecord::Base.connection.execute(row[0]) }
).to_a.map { |row| ActiveRecord::Base.connection.execute(row[0]) }
end

it 'can list tables' do
Expand Down

0 comments on commit ae01b55

Please sign in to comment.