From 7fb6e8767459ef5409c0763088e5d069a4d9a903 Mon Sep 17 00:00:00 2001 From: G0V1NDS Date: Sat, 29 Apr 2023 20:34:57 +0530 Subject: [PATCH 1/6] - Added URL param support for redis adapter --- autoload/db/adapter/redis.vim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/autoload/db/adapter/redis.vim b/autoload/db/adapter/redis.vim index 68e8a51..a1278e1 100644 --- a/autoload/db/adapter/redis.vim +++ b/autoload/db/adapter/redis.vim @@ -7,7 +7,22 @@ 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) + if k =~# '^\%(u\|r\|i\|d\|D\)$' && v isnot# 1 + call add(cmd, '-' . k . '=' . v) + elseif k =~# '^\%(sni\|cacert\|cacertdir\|cert\|key\|tls-ciphers\|tls-ciphersuites\|show-pushes\|lru-test\|rdb\|functions-rdb\|pipe-timeout\|memkeys-samples\|pattern\|quoted-pattern\|intrinsic-latency\|eval\|cluster\)$' && v isnot# 1 + call add(cmd, '--' . k . '=' . v) + elseif v =~# '^[1Tt]$' + if len(k) == 1 + call add(cmd, '-' . k) + else + call add(cmd, '--' . k) + endif + endif + endfor + return cmd + db#url#as_argv(a:url, '-h ', '-p ', '', '', '-a ', '-n ') endfunction function! db#adapter#redis#auth_input() abort From 9be782d63701cc3a97847120cbd09960d6cf08e4 Mon Sep 17 00:00:00 2001 From: G0V1NDS Date: Mon, 1 May 2023 16:44:30 +0530 Subject: [PATCH 2/6] - Limited the flag options to only connection params - Added comments --- autoload/db/adapter/redis.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoload/db/adapter/redis.vim b/autoload/db/adapter/redis.vim index a1278e1..b6b8a9b 100644 --- a/autoload/db/adapter/redis.vim +++ b/autoload/db/adapter/redis.vim @@ -10,11 +10,14 @@ function! db#adapter#redis#interactive(url) abort 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 =~# '^\%(u\|r\|i\|d\|D\)$' && v isnot# 1 call add(cmd, '-' . k . '=' . v) - elseif k =~# '^\%(sni\|cacert\|cacertdir\|cert\|key\|tls-ciphers\|tls-ciphersuites\|show-pushes\|lru-test\|rdb\|functions-rdb\|pipe-timeout\|memkeys-samples\|pattern\|quoted-pattern\|intrinsic-latency\|eval\|cluster\)$' && v isnot# 1 + elseif k =~# '^\%(cert\|key\|cacert\|capath\|tls-ciphers\|tls-ciphersuites\)$' && v isnot# 1 call add(cmd, '--' . k . '=' . v) elseif v =~# '^[1Tt]$' + " Some non-alias single char flags like `-c` needs to be passed + " with single hyphen `-` char if len(k) == 1 call add(cmd, '-' . k) else From f8b1d603765e16dd74e88a848563554bfe7b83e0 Mon Sep 17 00:00:00 2001 From: G0V1NDS Date: Mon, 1 May 2023 17:28:07 +0530 Subject: [PATCH 3/6] Updated redis connection help doc --- doc/dadbod.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/dadbod.txt b/doc/dadbod.txt index 38bf73b..22abbb2 100644 --- a/doc/dadbod.txt +++ b/doc/dadbod.txt @@ -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 ~ > From 52d1b196542d8d453d4b0ab3c69725a3e2eb67ac Mon Sep 17 00:00:00 2001 From: G0V1NDS Date: Mon, 8 May 2023 07:35:50 +0530 Subject: [PATCH 4/6] Removed support for single char flags u, r, i, d and D - These are not really required - We mainly needed to handle -c for cluster mode, which is already being handled by the else case --- autoload/db/adapter/redis.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/autoload/db/adapter/redis.vim b/autoload/db/adapter/redis.vim index b6b8a9b..1f4b81a 100644 --- a/autoload/db/adapter/redis.vim +++ b/autoload/db/adapter/redis.vim @@ -11,9 +11,7 @@ function! db#adapter#redis#interactive(url) abort 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 =~# '^\%(u\|r\|i\|d\|D\)$' && v isnot# 1 - call add(cmd, '-' . k . '=' . v) - elseif k =~# '^\%(cert\|key\|cacert\|capath\|tls-ciphers\|tls-ciphersuites\)$' && v isnot# 1 + if k =~# '^\%(cert\|key\|cacert\|capath\|tls-ciphers\|tls-ciphersuites\)$' && v isnot# 1 call add(cmd, '--' . k . '=' . v) elseif v =~# '^[1Tt]$' " Some non-alias single char flags like `-c` needs to be passed From b2602ca26e20152ae95f71ea34fbfede4ef2475f Mon Sep 17 00:00:00 2001 From: G0V1NDS Date: Sat, 20 May 2023 10:03:47 +0530 Subject: [PATCH 5/6] - Handled the supported boolean flag explicitly to avoid wrong input - Added appropriate error message with instruction to check the `dadbod-redis` help --- autoload/db/adapter/redis.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/db/adapter/redis.vim b/autoload/db/adapter/redis.vim index 1f4b81a..e6bd0b8 100644 --- a/autoload/db/adapter/redis.vim +++ b/autoload/db/adapter/redis.vim @@ -13,7 +13,7 @@ function! db#adapter#redis#interactive(url) abort " 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 v =~# '^[1Tt]$' + elseif k ==# 'c' && v =~# '^[1Tt]$' " Some non-alias single char flags like `-c` needs to be passed " with single hyphen `-` char if len(k) == 1 @@ -21,6 +21,8 @@ function! db#adapter#redis#interactive(url) abort else call add(cmd, '--' . k) endif + else + throw 'DB: unsupport URL param `' . k . '` in URL ' . a:url . ', Check `:help dadbod-redis`' endif endfor return cmd + db#url#as_argv(a:url, '-h ', '-p ', '', '', '-a ', '-n ') From 412e4e93df2f3eb0f097121f2989103c47c3a508 Mon Sep 17 00:00:00 2001 From: G0V1NDS Date: Thu, 10 Aug 2023 10:38:27 +0530 Subject: [PATCH 6/6] - Wrapped the help text to 78 chars --- doc/dadbod.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/dadbod.txt b/doc/dadbod.txt index 22abbb2..a7b0056 100644 --- a/doc/dadbod.txt +++ b/doc/dadbod.txt @@ -169,8 +169,8 @@ 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. +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 ~