Skip to content

Commit

Permalink
Add editor integration page
Browse files Browse the repository at this point in the history
  • Loading branch information
erik committed Jan 5, 2019
1 parent efaa0a3 commit 99f206c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 13 deletions.
13 changes: 0 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@ Catch unsafe SQL migrations.
performance issues.
...
Squabble works to help automate the process of reviewing SQL migrations
by catching simple mistakes, such as:

- Changing the type of an existing column
- Adding a new column with a default value or ``NOT NULL`` constraint
- Building an index without using ``CONCURRENTLY``

For more information on why these particular cases can be dangerous:

- https://www.braintreepayments.com/blog/safe-operations-for-high-volume-postgresql/
- https://blog.codeship.com/rails-migrations-zero-downtime/
- https://stripe.com/blog/online-migrations

Currently, most of the rules have been focused on Postgres and its
quirks. However, squabble can parse any ANSI SQL and new rules that are
specific to other databases are appreciated!
Expand Down
59 changes: 59 additions & 0 deletions docs/editors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Editor Integration
==================

Several editor syntax checkers already natively support the output
format for a similar tool, `sqlint <https://github.com/purcell/sqlint>`__,
which we can piggy-back off of by using the ``"sqlint"`` reporter.

Specific editors are mentioned below, but generally, if your editor
has support for ``sqlint`` and can customize the executable, try running
``squabble --reporter=sqlint`` instead!

emacs (via flycheck)
--------------------

The best way to configure squabble through flycheck would be to create
a new checker definition, which should Just Work when you open a SQL
file with flycheck turned on.

.. code-block:: elisp
(flycheck-define-checker sql-squabble
"A SQL syntax checker using the squabble tool.
See URL `https://github.com/erik/squabble'."
:command ("squabble" "--reporter=sqlint")
:standard-input t
:error-patterns
((warning line-start "stdin:" line ":" column ":WARNING "
(message (one-or-more not-newline)
(zero-or-more "\n"))
line-end)
(error line-start "stdin:" line ":" column " HIGH "
(message (one-or-more not-newline)
(zero-or-more "\n"))
line-end))
:modes (sql-mode))
(add-to-list 'flycheck-checkers 'sql-squabble)
Flycheck ships with support for `sqlint
<https://github.com/purcell/sqlint>`__, so if for whatever reason you
don't want to define a new checker, you should just be able to point
flycheck at the ``squabble`` executable.

.. code-block:: elisp
(custom-set-variable 'flycheck-sql-sqlint-executable "squabble")
Unfortunately flycheck does not allow user customization of the
command line arguments passed to the program, so you'll need to make
sure to have configuration file with ``{"reporter": "sqlint"}``.

vim (via syntastic)
-------------------

.. code-block:: vim
let g:syntastic_sql_sqlint_exec = "squabble"
let g:syntastic_sql_sqlint_args = "--reporter=sqlint"
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
:maxdepth: 3
:hidden:

editors
rules
plugins
api/index
Expand Down

0 comments on commit 99f206c

Please sign in to comment.