Skip to content

URL param support for redis adapter #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion autoload/db/adapter/redis.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,25 @@ function! db#adapter#redis#canonicalize(url) abort
endfunction

function! db#adapter#redis#interactive(url) abort
return ['redis-cli'] + db#url#as_argv(a:url, '-h ', '-p ', '', '', '-a ', '-n ')
let url = db#url#parse(a:url)
let cmd = ['redis-cli']
for [k, v] in items(url.params)
" Specifying only connection releated flag here, missing flags can be added later
if k =~# '^\%(cert\|key\|cacert\|capath\|tls-ciphers\|tls-ciphersuites\)$' && v isnot# 1
call add(cmd, '--' . k . '=' . v)
elseif k ==# 'c' && v =~# '^[1Tt]$'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the $ so that c=true can be used.

" Some non-alias single char flags like `-c` needs to be passed
" with single hyphen `-` char
if len(k) == 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is redundant, as k ==# 'c' implies len(k) == 1.

call add(cmd, '-' . k)
else
call add(cmd, '--' . k)
endif
else
throw 'DB: unsupport URL param `' . k . '` in URL ' . a:url . ', Check `:help dadbod-redis`'
Comment on lines +24 to +25
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this.

endif
endfor
return cmd + db#url#as_argv(a:url, '-h ', '-p ', '', '', '-a ', '-n ')
endfunction

function! db#adapter#redis#auth_input() abort
Expand Down
3 changes: 3 additions & 0 deletions doc/dadbod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ Redis ~
Redis doesn't have a username, so use a dummy one in the URL if a password is
required.

Query parameters such as `c`, `cert`, `key`, `cacert`, `capath`, `tls-ciphers`
and `tls-ciphersuites` are passed as the corresponding command line options.

*dadbod-sqlserver*
SQL Server ~
>
Expand Down