Skip to content

Commit 5e1b5ab

Browse files
committed
Handle v:null and booleans in database config
1 parent 6e8e02a commit 5e1b5ab

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

autoload/rails.vim

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4310,6 +4310,13 @@ function! s:app_db_config(environment) dict
43104310
elseif self.has_path('config/database.yml')
43114311
try
43124312
let all = rails#yaml_parse_file(self.path('config/database.yml'))
4313+
for [e, c] in items(all)
4314+
for [k, v] in type(c) ==# type({}) ? items(c) : []
4315+
if type(v) ==# get(v:, 't_none', 7)
4316+
call remove(c, k)
4317+
endif
4318+
endfor
4319+
endfor
43134320
call self.cache.set('db_config', all)
43144321
catch /^invalid/
43154322
endtry
@@ -4346,7 +4353,12 @@ function! s:app_db_config(environment) dict
43464353
endfunction
43474354

43484355
function! s:url_encode(str, ...) abort
4349-
return substitute(a:str, '[?@=&<>%#[:space:]' . (a:0 && a:1 == 'path' ? '' : ':/').']', '\=printf("%%%02X", char2nr(submatch(0)))', 'g')
4356+
if type(a:str) ==# get(v:, 't_bool', 6)
4357+
let str = a:str ? 'true' : 'false'
4358+
else
4359+
let str = a:str
4360+
endif
4361+
return substitute(str, '[?@=&<>%#[:space:]' . (a:0 && a:1 == 'path' ? '' : ':/').']', '\=printf("%%%02X", char2nr(submatch(0)))', 'g')
43504362
endfunction
43514363

43524364
function! s:app_db_url(...) dict abort

0 commit comments

Comments
 (0)