File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
lib/ruby_lsp/ruby_lsp_rails Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,9 @@ def resolve_database_info_from_model(model_name)
42
42
}
43
43
44
44
if ActiveRecord ::Tasks ::DatabaseTasks . respond_to? ( :schema_dump_path )
45
- info [ :schema_file ] = ActiveRecord ::Tasks ::DatabaseTasks . schema_dump_path ( const . connection . pool . db_config )
45
+ info [ :result ] [ :schema_file ] =
46
+ ActiveRecord ::Tasks ::DatabaseTasks . schema_dump_path ( const . connection . pool . db_config )
47
+
46
48
end
47
49
info
48
50
rescue => e
Original file line number Diff line number Diff line change @@ -31,6 +31,15 @@ class RunnerClientTest < ActiveSupport::TestCase
31
31
assert_match ( %r{db/schema\. rb$} , response . fetch ( :schema_file ) )
32
32
end
33
33
34
+ test "handles older Rails version which don't have `schema_dump_path`" do
35
+ ActiveRecord ::Tasks ::DatabaseTasks . send ( :alias_method , :old_schema_dump_path , :schema_dump_path )
36
+ ActiveRecord ::Tasks ::DatabaseTasks . undef_method ( :schema_dump_path )
37
+ response = T . must ( @client . model ( "User" ) )
38
+ assert_nil ( response [ :schema_file ] )
39
+ ensure
40
+ ActiveRecord ::Tasks ::DatabaseTasks . send ( :alias_method , :schema_dump_path , :old_schema_dump_path )
41
+ end
42
+
34
43
test "returns nil if model doesn't exist" do
35
44
assert_nil @client . model ( "Foo" )
36
45
end
You can’t perform that action at this time.
0 commit comments