5959(defvar-local lsp-mssql-buffer-status nil
6060 " SQL buffer status." )
6161
62+ (defvar-local lsp-mssql-result-metadata nil
63+ " Metadata associated with result set.
64+
65+ This is stored in the result buffer as buffer local value." )
66+
6267(put 'lsp-mssql-buffer-status 'risky-local-variable t )
6368(add-to-list 'global-mode-string (list '(t lsp-mssql-buffer-status)))
6469
@@ -243,11 +248,16 @@ PARAMS the params."
243248 " Result set complete handler.
244249WORKSPACE is the active workspace.
245250PARAMS the params."
246- (-let* ((marker (lsp-mssql-with-result-buffer
251+ (-let* ((column-info (gethash " columnInfo" (gethash " resultSetSummary" params)))
252+ (result-metadata (seq-map (-lambda ((&hash " columnName" name " dataTypeName" type))
253+ (list name :name name :type type))
254+ column-info))
255+ (marker (lsp-mssql-with-result-buffer
256+ (setq-local lsp-mssql-result-metadata result-metadata)
247257 (goto-char (point-max ))
248258 (insert (format " |%s |\n " (s-join " |" (seq-map (-lambda ((&hash " columnName" name))
249259 name)
250- ( gethash " columnInfo " ( gethash " resultSetSummary " params)) ))))
260+ column-info ))))
251261 (insert " |-" )
252262 (org-table-align )
253263 (goto-char (point-at-eol ))
@@ -264,11 +274,11 @@ PARAMS the params."
264274 (- row-count loaded-index)
265275 to-load)))
266276 `(:ownerUri , owner-uri
267- :resultSetIndex , id
268- :rowsCount , to-load
269- :rowsStartIndex ,(prog1 loaded-index
270- (setf loaded-index (+ loaded-index to-load)))
271- :batchIndex , batchId ))
277+ :resultSetIndex , id
278+ :rowsCount , to-load
279+ :rowsStartIndex ,(prog1 loaded-index
280+ (setf loaded-index (+ loaded-index to-load)))
281+ :batchIndex , batchId ))
272282 (lsp--info " All items are loaded" )
273283 nil )))
274284 (when-let ((params (subset-params)))
@@ -306,10 +316,9 @@ PARAMS the params."
306316 (define-key [mouse-2] 'push-button ))
307317 'help-echo " mouse-2, M-RET: Load more items." ))
308318 (insert " \n\n " )
309- (org-mode )
310319 (goto-char (marker-position marker))
311320 (org-table-align )
312- (pop-to -buffer (current-buffer ))))
321+ (display -buffer (current-buffer ))))
313322 :mode 'detached ))))))
314323
315324(defun lsp-mssql--batch-complete (_workspace _params )
@@ -344,7 +353,7 @@ PARAMS batch handler params."
344353 ; ; ("character" endColumn))))))
345354 ; ; (insert "#+END_SRC\n\n")
346355 )
347- (display-buffer-in-side-window (current-buffer ) '((side . bottom) ))))
356+ (display-buffer (current-buffer ))))
348357
349358(defun lsp-mssql--connection-changed (_workspace _params )
350359 " Hanler for batch complete." )
@@ -436,6 +445,11 @@ PARAMS batch handler params."
436445 (erase-buffer ))
437446 (lsp-request " query/executeDocumentSelection" (list :ownerUri (lsp--buffer-uri))))
438447
448+ (defun lsp-mssql-cancel ()
449+ " Cancel the current query."
450+ (interactive )
451+ (lsp-request " query/cancel" (list :ownerUri (lsp--buffer-uri))))
452+
439453
440454; ; object explorer
441455
0 commit comments