Skip to content

Formatter and language server for T-SQL written using Rust

Notifications You must be signed in to change notification settings

alira008/Irosql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Irosql

Todo

I plan to add ability to launch language server or format given input to this CLI

Language Server

Todo

My Language Server for T-SQL. Thinking about making this work for possibly SSMS but also trying to make it work for Neovim

Parser

Parses T-SQL queries and places them into abstract syntax to make it easier for other crates make sense of the queries that are given to it

Formatter

Formats T-SQL queries into a standardized readable format. Settings are inspired by Poor Man's TSQL Formatter. Right now this is a CLI where you pass options and pass the input and it outputs result query into stdout. Errors are returned in stderr.

Example run

formatter -k upper -b -i 'select top 50 percent LastPrice, HighPrice, LowPrice, QuoteTime from Market mt where QuoteTime > '\''6:30'\'' and PercentChange > 0 oRDer By Symbol'

Output

SELECT TOP 50 PERCENT LastPrice
    ,HighPrice
    ,LowPrice
    ,QuoteTime
FROM Market mt
WHERE QuoteTime > '6:30'
    AND PercentChange > 0
ORDER BY Symbol

Help

Usage: formatter [OPTIONS] <INPUT>

Arguments:
  <INPUT>

Options:
  -c, --indent-comma-lists <INDENT_COMMA_LISTS>
          [possible values: trailing-comma, space-after-comma]
  -i, --indent-in-lists

  -b, --indent-between-conditions

  -k, --keyword-case <KEYWORD_CASE>
          [default: upper] [possible values: upper, lower]
  -m, --max-width <MAX_WIDTH>
          [default: 80]
  -w, --indent-width <INDENT_WIDTH>
          [default: 4]
  -u, --use-tab

  -h, --help
          Print help
  -V, --version
          Print version

Features In Progress

  • Select Queries

    • [ ALL | DISTINCT ]
    • TOP (expression) [ PERCENT ] | [ WITH TIES ]
    • select items
      • with subqueries
      • with numbers
      • with identifiers
      • with aliases
      • with aggregate functions
    • from clause
      • basic table
      • table with alias
      • table valued function
      • pivot table
      • unpivot table
      • joins
    • where clause
      • with subqueries
      • with numbers
      • with identifiers
      • with aggregate functions
    • group by clause
      • with numbers
      • with identifiers
      • with aggregate functions
    • having clause
      • with subqueries
      • with numbers
      • with identifiers
      • with aggregate functions
    • order by clause
      • with numbers
      • with identifiers
  • CTEs

  • Insert Queries

  • Bulk Insert Queries

  • Delete Queries

  • Update Queries

  • Unions

About

Formatter and language server for T-SQL written using Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages