All Projects → joereynolds → Sql Lint

joereynolds / Sql Lint

Licence: mit
An SQL linter

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Sql Lint

Sqlx
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.
Stars: ✭ 5,039 (+1973.66%)
Mutual labels:  sql, mysql, postgresql, postgres
Sqliterally
Lightweight SQL query builder
Stars: ✭ 231 (-4.94%)
Mutual labels:  sql, mysql, postgresql, postgres
Sql
MySQL & PostgreSQL pipe
Stars: ✭ 81 (-66.67%)
Mutual labels:  sql, mysql, postgresql, postgres
Jet
Type safe SQL builder with code generation and automatic query result data mapping
Stars: ✭ 373 (+53.5%)
Mutual labels:  sql, mysql, postgresql, postgres
Vscode Sqltools
Database management for VSCode
Stars: ✭ 741 (+204.94%)
Mutual labels:  sql, mysql, postgresql, postgres
Goqu
SQL builder and query library for golang
Stars: ✭ 984 (+304.94%)
Mutual labels:  sql, mysql, postgresql, postgres
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+421.4%)
Mutual labels:  sql, mysql, postgresql, postgres
Nut
Advanced, Powerful and easy to use ORM for Qt
Stars: ✭ 181 (-25.51%)
Mutual labels:  sql, mysql, postgresql
Condenser
Condenser is a database subsetting tool
Stars: ✭ 189 (-22.22%)
Mutual labels:  mysql, postgresql, postgres
Django Migration Linter
🚀 Detect backward incompatible migrations for your django project
Stars: ✭ 231 (-4.94%)
Mutual labels:  linter, mysql, postgresql
Scany
Library for scanning data from a database into Go structs and more
Stars: ✭ 228 (-6.17%)
Mutual labels:  sql, mysql, postgresql
Sqlcheck
Automatically identify anti-patterns in SQL queries
Stars: ✭ 2,062 (+748.56%)
Mutual labels:  sql, mysql, postgresql
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+852.67%)
Mutual labels:  sql, mysql, postgres
Massive Js
A data mapper for Node.js and PostgreSQL.
Stars: ✭ 2,521 (+937.45%)
Mutual labels:  sql, postgresql, postgres
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+809.88%)
Mutual labels:  sql, mysql, postgresql
Npgsql
Npgsql is the .NET data provider for PostgreSQL.
Stars: ✭ 2,415 (+893.83%)
Mutual labels:  sql, postgresql, postgres
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (-30.45%)
Mutual labels:  sql, mysql, postgresql
Shardingsphere
Build criterion and ecosystem above multi-model databases
Stars: ✭ 14,989 (+6068.31%)
Mutual labels:  sql, mysql, postgresql
Fluentmigrator
Fluent migrations framework for .NET
Stars: ✭ 2,636 (+984.77%)
Mutual labels:  sql, mysql, postgres
Heidisql
A lightweight client for managing MariaDB, MySQL, SQL Server, PostgreSQL and SQLite, written in Delphi
Stars: ✭ 2,864 (+1078.6%)
Mutual labels:  sql, mysql, postgresql

sql-lint

Build Status

sql-lint will do sanity checks on your queries as well as bring errors back from the DB. If you worry about forgetting WHEREs on a DELETE or borking your data with unexpected characters, then sql-lint is for you.

A complete list of the checks it does is below.

Imgur

Imgur

Installation

npm install -g sql-lint

Or download a binary

Usage

sql-lint works on files, directories and stdin.

# Will lint all .sql files recursively from the current directory
sql-lint .

# Lints the create-person.sql file
sql-lint create-person.sql

# Lints stdin
echo 'DELETE FROM person;' | sql-lint

Editor Integration

If your editor supports external tools, then it supports sql-lint. Below is the list that have direct support for sql-lint either through plugins or configuration.

(Neo)Vim

(Neo)Vim can be configured to use sql-lint on .sql files.

Ale ships with sql-lint support out the box.

If you do not want to use a plugin, a much more lightweight solution is to run the following in an .sql file:

:!sql-lint %

Checks

sql-lint comes with its own suite of checks. It also returns any errors from the SQL server you have connected to. Generally you'll find that the errors from sql-lint are more informative than those from the server. That said, you will still want errors from the server as it covers more cases and will catch things that sql-lint does not.

unmatched-parentheses

Shown when a query has an unbalanced amount of parentheses.

test/test-files//test.sql:16 [sql-lint: unmatched-parentheses] Unmatched parentheses.

missing-where

Shown when a DELETE statement is missing a WHERE clause.

test/test-files/test.sql:20 [sql-lint: missing-where] DELETE statement missing WHERE clause.

invalid-drop-option

Shown when an invalid option is given to the DROP statement.

test/test-files/test.sql:22 [sql-lint: invalid-drop-option] Option 'thing' is not a valid option, must be one of '["database","event","function","index","logfile","procedure","schema","server","table","view","tablespace","trigger"]'.

invalid-create-option

Shown when an invalid option is given to the CREATE statement.

:24 [sql-lint: invalid-create-option] Option 'test' is not a valid option, must be one of '["algorithm","database","definer","event","function","index","or","procedure","server","table","tablespace","temporary","trigger","user","unique","view"]'.

invalid-truncate-option

Shown when an invalid option is given to the TRUNCATE statement.

test/test-files/test.sql:26 [sql-lint: invalid-truncate-option] Option 'something' is not a valid option, must be one of '["table"]'.

invalid-alter-option

Shown when an invalid option is given to the ALTER statement.

test/test-files/test.sql:28 [sql-lint: invalid-alter-option] Option 'mlady' is not a valid option, must be one of '["column","online","offline","ignore","database","event","function","procedure","server","table","tablespace","view"]'.

odd-code-point

Shown when there are unsupported/unusual* code points in your code.

*This check came about whilst working Microsoft Excel. Microsoft likes to add a lot of zany characters which can subtly break your data without you realising.

test/test-files//test.sql:30 [sql-lint: odd-code-point] Unexpected code point.

invalid-limit-quantifier

Shown when you specify something other than a number to the LIMIT statement.

test/test-files//test.sql:32 [sql-lint: invalid-limit-quantifier] Argument 'test' is not a valid quantifier for LIMIT clause.

hungarian-notation

Shown when the string sp_ or tbl_ is present in the query.

test/test-files/test.sql:34 [sql-lint: hungarian-notation] Hungarian notation present in query

trailing-whitespace

Shown when a query has trailing whitespace.

test/test-files/test.sql:34 [sql-lint: trailing-whitespace] Trailing whitespace

Read more

To find out more, read the documentation

Need help?

There's a room on gitter for sql-lint.

Come by and I'll do my best to help.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].