Skip to content

Commit 630fc98

Browse files
committed
Rewrite unless/else as if/else
I believe it is generally accepted that unless/else is hard to read, too many negations.
1 parent 2aeb322 commit 630fc98

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

activerecord/lib/active_record/connection_adapters/sqlite3/database_statements.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ def internal_exec_query(sql, name = nil, binds = [], prepare: false, async: fals
3131

3232
log(sql, name, binds, type_casted_binds, async: async) do |notification_payload|
3333
with_raw_connection do |conn|
34-
# Don't cache statements if they are not prepared
35-
unless prepare
34+
if prepare
35+
stmt = @statements[sql] ||= conn.prepare(sql)
36+
cols = stmt.columns
37+
stmt.reset!
38+
stmt.bind_params(type_casted_binds)
39+
records = stmt.to_a
40+
else
41+
# Don't cache statements if they are not prepared.
3642
stmt = conn.prepare(sql)
3743
begin
3844
cols = stmt.columns
@@ -43,12 +49,6 @@ def internal_exec_query(sql, name = nil, binds = [], prepare: false, async: fals
4349
ensure
4450
stmt.close
4551
end
46-
else
47-
stmt = @statements[sql] ||= conn.prepare(sql)
48-
cols = stmt.columns
49-
stmt.reset!
50-
stmt.bind_params(type_casted_binds)
51-
records = stmt.to_a
5252
end
5353
verified!
5454

0 commit comments

Comments
 (0)