Skip to content

Commit

Permalink
Add proper support for mariadb scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
kristijanhusak committed Jun 20, 2024
1 parent 833c1d4 commit a95d8b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 1 addition & 6 deletions autoload/db_ui.vim
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,9 @@ function! s:dbui.populate_schema_info(db) abort
let parsed_url = self.parse_url(url)
let scheme = get(parsed_url, 'scheme', '')
let scheme_info = db_ui#schemas#get(scheme)
let schema_support = !empty(get(scheme_info, 'schemes_query', 0))
if schema_support && tolower(scheme) ==? 'mysql' && parsed_url.path !=? '/'
let schema_support = 0
endif

let a:db.scheme = scheme
let a:db.table_helpers = db_ui#table_helpers#get(scheme)
let a:db.schema_support = schema_support
let a:db.schema_support = db_ui#schemas#supports_schemes(scheme_info, parsed_url)
let a:db.quote = get(scheme_info, 'quote', 0)
let a:db.default_scheme = get(scheme_info, 'default_scheme', '')
let a:db.filetype = get(scheme_info, 'filetype', 'sql')
Expand Down
15 changes: 15 additions & 0 deletions autoload/db_ui/schemas.vim
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,18 @@ function! db_ui#schemas#query(db, scheme, query) abort
let result = call('db#systemlist', s:format_query(a:db, a:scheme, a:query))
return map(result, {_, val -> substitute(val, "\r$", "", "")})
endfunction

function db_ui#schemas#supports_schemes(scheme, parsed_url)
let schema_support = !empty(get(a:scheme, 'schemes_query', 0))
if empty(schema_support)
return 0
endif
let scheme_name = tolower(get(a:parsed_url, 'scheme', ''))
" Mysql and MariaDB should not show schemas if the path (database name) is
" defined
if (scheme_name ==? 'mysql' || scheme_name ==? 'mariadb') && a:parsed_url.path !=? '/'
return 0
endif

return 1
endfunction
1 change: 1 addition & 0 deletions autoload/db_ui/table_helpers.vim
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ let s:helpers = {
\ 'bigquery': s:bigquery,
\ 'postgresql': s:postgres,
\ 'mysql': s:mysql,
\ 'mariadb': s:mysql,
\ 'oracle': s:oracle,
\ 'sqlite': s:sqlite,
\ 'sqlserver': s:sqlserver,
Expand Down

0 comments on commit a95d8b6

Please sign in to comment.