Skip to content

Commit

Permalink
Add ejc-connect keybinding, update package obtaining for Oracle DBs.
Browse files Browse the repository at this point in the history
  • Loading branch information
kostafey committed Mar 29, 2019
1 parent 14582d6 commit 54bb92f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ New keybindings defined in `ejc-sql-mode` minor mode:

Keyboard shortcut | Command | Description
---------------------|---------------------------------|------------------------------------------------------
<kbd>C-c C-c</kbd> | `ejc-eval-user-sql-at-point` | Evaluate SQL/JPQL script bounded by the `ejc-sql-separator` or/and buffer boundaries.
<kbd>C-c e c</kbd> | `ejc-connect` | Select DB connection (configured by `ejc-create-connection`) and connect to it.
<kbd>C-c C-c</kbd> | `ejc-eval-user-sql-at-point` | Evaluate SQL script bounded by the `ejc-sql-separator` or/and buffer boundaries.
<kbd>C-g</kbd> | `ejc-cancel-query` | Terminate current running query or run `keyboard-quit` if there is no running queries.
<kbd>C-h t</kbd> | `ejc-describe-table` | Describe SQL table.
<kbd>C-h d</kbd> | `ejc-describe-entity` | Get entity definition: show creation SQL of view, package, function, procedure or type.
Expand Down
2 changes: 1 addition & 1 deletion ejc-autocomplete.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Uppercase by default, set to nil to use downcase candidates."

(defvar ejc-ansi-sql-words
'("select" "where" "and" "or" "from" "insert" "update" "delete" "join"
"order" "by" "distinct" "create" "alter" "drop" "like"
"order by" "distinct" "create" "alter" "drop" "like"
"grant" "revoke" "deny" "commit" "rollback" "savepoint"))

(defvar ejc-auxulary-sql-words
Expand Down
1 change: 1 addition & 0 deletions ejc-sql.el
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ results. When nil, otherwise, provide `ejc-sql' users expected behaviour."

(defvar ejc-command-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "c") #'ejc-connect)
(define-key map (kbd "<up>") #'ejc-show-last-result)
(define-key map (kbd "t") #'ejc-show-tables-list)
(define-key map (kbd "v") #'ejc-show-views-list)
Expand Down
28 changes: 24 additions & 4 deletions src/ejc_sql/structure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,30 @@
:package (fn [& {:keys [entity-name]}]
;; entity-name is a package name here
(format "
SELECT text FROM all_source
WHERE UPPER(name) = '%s'
AND type = 'PACKAGE BODY'
ORDER BY line " (s/upper-case entity-name)))
SELECT text FROM
(
SELECT text AS text,
1 AS ordered,
line AS line
FROM all_source
WHERE UPPER(name) = '%s'
AND type = 'PACKAGE'
UNION SELECT '\n\n', 2, 1 from dual
UNION SELECT ' ------------------\n', 3, 1 from dual
UNION SELECT ' -- PACKAGE BODY --\n', 4, 1 from dual
UNION SELECT ' ------------------\n', 5, 1 from dual
UNION SELECT '\n', 6, 1 from dual
UNION
SELECT text,
7,
line
FROM all_source
WHERE UPPER(name) = '%s'
AND type = 'PACKAGE BODY'
)
ORDER BY ordered, line "
(s/upper-case entity-name)
(s/upper-case entity-name)))
:table (fn [& {:keys [entity-name]}]
(format "
SELECT dbms_metadata.get_ddl('TABLE','%s')
Expand Down

0 comments on commit 54bb92f

Please sign in to comment.