SQL Formatter Library

SQL Formatter Library (ODC)

Stable version 0.1.8 (Compatible with ODC)
Uploaded on 04 April 2024 by Product League
SQL Formatter Library

SQL Formatter Library (ODC)

Documentation
0.1.8

For better understanding, it's advisable to refer to both this documentation and the accompanying demo application. The demo application can be found as SQL Formatter Demo as an ODC Forge Component.


1. Install the latest component version

Check the OutSystems Forge for the SQL Formatter Library component and ensure that the latest version is installed in your environment. Remember to also check and compatibilize the dependency to SQLFormatter (also on ODC Forge) If both are not installed, proceed with the installation.


2. Manage your dependencies

Add a desired dependency in your application or library from the SQL Formatter Library through manage dependencies and choose 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 server action according to your use case



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.