sql-formatter
Reactive icon

SQL Formatter

Stable version 1.0.3 (Compatible with OutSystems 11)
Uploaded
 on 4 Jun
 by 
5.0
 (6 ratings)
sql-formatter

SQL Formatter

Documentation
1.0.1

For better understanding, it's advisable to refer to both this documentation and the accompanying demo application. The demo application can be included during the installation of the component


1. Install the latest component version

Check the OutSystems Forge for the SQL Formatter component and ensure that the latest version is installed in your environment. If it's not installed, proceed with the installation. This component doesn't have any additional dependencies. You can also download and install the demo application at this time.


2. Manage your dependencies

Add a desired dependency in your module from the SQLFormatter_Lib (not the SQLFormatter extension) through manage dependencies and choose from the SQLFormatter Block or directly the Server Actions (whichever suits you for your use-case).




3. Using the SQLFormatter block

Drag and Drop or add the block element to your screen/block element 


Fill the block parameters:

The mandatory SQL with the string to be formatted or coloured.

When using the desired FormattingOptions [not mandatory] you can set:

  • Indent String [text]: Strings used for indentation being the default “\t”

  • Spaces Per Tab [integer]: Number of spaces assigned for tabulation.

  • Max Line Width [integer]: Char maximum number per line.

  • New Statement Line Breaks [integer]: Number of Lines separating each statement.

  • New Clause Line Breaks [integer]: Number of Lines separating each clause.

  • Expand Comma Lists [boolean]: Sets commas in new lines if true, or just plain followed text if false.

  • Trailing Commas [boolean]: Sets trailing commas after attributes if selected as true.

  • Space After Comma [boolean]: If Expand Comma Lists is set as True, you also add a space in between commas and selected attributes when this property is selected.

  • Expand Boolean Expressions [boolean]: Expands booleans expressions on different lines.

  • Expand Case Statements [boolean]: Expands cases on different lines.

  • Expand Between Conditions [boolean]: Expands betweens with conditions on different lines.

  • Break Join On Sections [boolean]: Breaks join statements on different sections.

  • Uppercase Keywords [boolean]: Sets keywords as uppercase/lowercase.

  • HTML Coloring [boolean]: Sets the response as HTML with different styles for Operators, Functions,Comments,String,Keyword and ErrorHighlights

ExtendedClass [not mandatory]: Add custom style classes to the pattern. You define your custom style classes in you application using CSS.

Lastly with the ColorizeOnly [boolean] option, only colorizes your query in an html response, without formatting it, thus ignoring all the FormattingOptions.


4. Using the public Server Actions

For different usability purposes, you can choose to call directly the availble Server Actions instead of using the public SQLFormatter Block:

  • GetColorizedSQL: Colorizes a given SQL query in a html response without formatting options.


  • GetFormattedSQL: Formats a given SQL query based on a subset of Formatting Options.