File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change 11
11
module ActiveRecord
12
12
module CockroachDB
13
13
class UnloggedTablesTest < ActiveRecord ::PostgreSQLTestCase
14
- include SchemaDumpingHelper
15
14
16
15
TABLE_NAME = "things"
17
16
LOGGED_FIELD = "relpersistence"
@@ -24,24 +23,18 @@ class Thing < ActiveRecord::Base
24
23
self . table_name = TABLE_NAME
25
24
end
26
25
27
- def setup
28
- @connection = ActiveRecord ::Base . lease_connection
29
- ActiveRecord ::ConnectionAdapters ::PostgreSQLAdapter . create_unlogged_tables = false
30
- end
31
-
32
- teardown do
33
- @connection . drop_table TABLE_NAME , if_exists : true
34
- ActiveRecord ::ConnectionAdapters ::PostgreSQLAdapter . create_unlogged_tables = false
35
- end
36
-
37
26
# Cockroachdb ignores the UNLOGGED specifier.
38
27
# https://github.com/cockroachdb/cockroach/issues/56827
39
28
def test_unlogged_in_test_environment_when_unlogged_setting_enabled
29
+ @original_create_unlogged_tables = ActiveRecord ::ConnectionAdapters ::PostgreSQLAdapter . create_unlogged_tables
40
30
ActiveRecord ::ConnectionAdapters ::PostgreSQLAdapter . create_unlogged_tables = true
31
+ connection = ActiveRecord ::Base . lease_connection
41
32
42
- @ connection. create_table ( TABLE_NAME ) do |t |
33
+ connection . create_table ( TABLE_NAME ) do |t |
43
34
end
44
- assert_equal @connection . execute ( LOGGED_QUERY ) . first [ LOGGED_FIELD ] , LOGGED
35
+ assert_equal connection . execute ( LOGGED_QUERY ) . first [ LOGGED_FIELD ] , LOGGED
36
+ ensure
37
+ ActiveRecord ::ConnectionAdapters ::PostgreSQLAdapter . create_unlogged_tables = @original_create_unlogged_tables
45
38
end
46
39
end
47
40
end
You can’t perform that action at this time.
0 commit comments