Skip to content

Commit e282f4e

Browse files
committed
fix: Solve transaction block warning
1 parent 6338982 commit e282f4e

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

app/controllers/concerns/row_level_security.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ def with_rls_context
4343
end
4444

4545
yield
46+
47+
# Reset PostgreSQL variables within the same transaction
48+
begin
49+
connection.execute('RESET app.current_user_id;')
50+
connection.execute('RESET app.current_organization_id;')
51+
connection.execute('RESET app.user_role;')
52+
rescue ActiveRecord::StatementInvalid
53+
# Ignore reset errors
54+
end
4655
end
4756
ensure
48-
# Reset PostgreSQL variables
49-
begin
50-
ActiveRecord::Base.connection.execute('RESET app.current_user_id;')
51-
ActiveRecord::Base.connection.execute('RESET app.current_organization_id;')
52-
ActiveRecord::Base.connection.execute('RESET app.user_role;')
53-
rescue ActiveRecord::StatementInvalid
54-
# Connection might be closed, ignore
55-
end
56-
5757
# Reset thread-local variables
5858
Thread.current[:current_organization_id] = nil
5959
Thread.current[:current_user_id] = nil

0 commit comments

Comments
 (0)