forked from TaoK/PoorMansTSqlFormatter
-
Notifications
You must be signed in to change notification settings - Fork 0
A small free .Net 2.0 library (with demo UI, command-line bulk formatter, SSMS add-in, and web service) for reformatting and coloring T-SQL code to the user's preferences.
License
AGPL-3.0, Unknown licenses found
Licenses found
AGPL-3.0
LICENSE.txt
Unknown
LICENSE.rtf
Rock-VbCity/PoorMansTSqlFormatter
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Poor Man's T-SQL Formatter -------------------------- This is a small free .Net 2.0 library (with demo winforms program, web service, SSMS Addin, Command-line utility, and WinMerge plugin) for reformatting T-SQL code. Features: - Simple Xml-based parse tree - Extensible, with possibility of supporting other SQL dialects (but none implemented) - Configurable according to SQL formatting preferences - Handles "procedural" T-SQL; this is not just a SQL statement formatter, but it also formats entire batches, and multi-batch scripts. - Optional colorized HTML output - Fault-tolerant parsing and formatting - if some unknown SQL construct is encountered or a keyword is misinterpreted, parsing does not fail (but will simply not colorize or indent that portion correctly). If the parsing fails more catastrophically, a "best effort" will be made and warning displayed (or in the case of interactive use, eg in SSMS, the operation can be aborted). - Reasonably fast: reformatting 1,500 or so files totalling 4MB takes 30 seconds on a cheap atom-processor (2009) netbook. - Works in Microsoft .Net framework, as well as Mono. The Winforms Demo App is not (yet?) available in Mono, but the library itself is fully functional, as is the command-line bulk formatting tool. Limitations: - This is NOT a full SQL-parsing solution: only "coarse" parsing is performed, the minimum necessary for re-formatting. - The standard formatter does not always maintain the order of comments in the code; a comment inside an "INNER JOIN" compound keyword, like "inner/*test*/join", would get moved out, to "INNER JOIN /*test*/". The original data is maintaned in the parse tree, but the standard formatter shuffles comments in cases like this for clarity. - DDL parsing, in particular, is VERY coarse - the bare minimum to display ordered table column and procedure parameter declarations. - No effort has been made to support compatibility level 70 (SQL Server 7) - Where there is ambiguity between different compatibility levels (eg cross apply parens in compatibility level 90 vs table hints without "WITH" keyword in compatibility level 80), no approach has been decided. For now, table hints without WITH are considered to be arguments to a function. Known Issues / Todo: - Handling of DDL Triggers (eg "FOR LOGON") - Formatting/indenting of ranking functions - FxCop checking - And other stuff that is tracked in the GitHub issues list Longer-term enhancements / additions: - Compiled mono library + bulk formatting tool download (eg for use on SVN server) - Documentation of Xml structure and class usage - Pakaging, NuGet and/or OpenWrap - Keeping track of versioning and documentation more carefully: http://semver.org/ This application and library is released under the GNU Affero GPL v3: http://www.gnu.org/licenses/agpl.txt The homepage for this project is currently: http://www.architectshack.com/PoorMansTSqlFormatter.ashx This project uses several external libraries: - NDesk.Options, for command-line parsing: The NDesk.Options library is licensed under the MIT/X11 license, and its homepage is here: http://www.ndesk.org/Options - LinqBridge, for convenience, supporting extension methods and Linq-to-Objects despite this being a .Net 2.0 library. LinqBridge is licensed under the BSD 3-clause license, and its homepage is here: http://code.google.com/p/linqbridge/ Please contact me with any questions, concerns, or issues: my email address starts with tao, and is hosted at klerks dot biz. Tao Klerks
About
A small free .Net 2.0 library (with demo UI, command-line bulk formatter, SSMS add-in, and web service) for reformatting and coloring T-SQL code to the user's preferences.
Resources
License
AGPL-3.0, Unknown licenses found
Licenses found
AGPL-3.0
LICENSE.txt
Unknown
LICENSE.rtf
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published