Skip to content

Feature Request: Enhanced SQL String Conversion for the Editor Enhancements Wizard #219

@dimitar-grigorov

Description

@dimitar-grigorov

I would like to propose an enhancement that builds on the existing Convert to String functionality under CnPack Editor MenuOthers. The idea is to offer a similar conversion tool, but with additional options—either as a separate menu "SQL Conversion" submenu entry or as an enhancement to the current functionality.

Proposed Enhancements:

  1. Bi-directional Conversion

    • Raw SQL to Delphi String:
      Convert a standard SQL query into Delphi string literals.
      Example:

      SELECT                                              
        o.order_id,
        o.total
      FROM
        orders o
      WHERE
        o.order_id = 200

      converts into:

      'SELECT' + #13#10 +
      '  o.order_id,' + #13#10 +
      '  o.total' + #13#10 +
      'FROM' + #13#10 +
      '  orders o' + #13#10 +
      'WHERE' + #13#10 +
      '  o.order_id = 200'
    • Delphi String to Raw SQL:
      Allow conversion in the reverse direction—from Delphi string formatted SQL back to a standard raw SQL query—to facilitate easy copying and execution in an SQL manager.

  2. Aligned Concatenation Operator

    • Vertical Alignment Option:
      Introduce an option to pad the string literals so that the concatenation operator (+ #13#10 +) aligns vertically. This would improve readability and maintain the original indentation of the SQL query.

      Example:

      'SELECT            ' + #13#10 +
      '  o.order_id,     ' + #13#10 +
      '  o.total         ' + #13#10 +
      'FROM              ' + #13#10 +
      '  orders o        ' + #13#10 +
      'WHERE             ' + #13#10 +
      '  o.order_id = 200'
    • Configuration Option for Padding:
      Allow users to choose whether to enable the alignment option and to configure the number of spaces applied after the longest line.

  3. Enhanced or Separate Menu Option

    • Separate Menu Entry or Enhanced Options:
      I propose that this enhanced conversion functionality be either offered in a separate menu (for example, an "SQL Conversion" submenu) or by enhancing the current Convert to String option with additional configurable settings. This would let users toggle between different conversion modes without cluttering the existing tool.
  4. Additional Ideas

    • SQL Formatting Options:
      In addition to conversion, it could be beneficial to provide formatting settings (e.g., preserving original indentation, automatic case conversion for SQL keywords, etc.).

    • Integrated Workflow:
      Enable a seamless workflow where developers can quickly switch between raw SQL and Delphi string formats with a single command, reducing manual editing steps.

I believe these enhancements would significantly improve the SQL conversion tool’s flexibility and usability. I'm looking forward to feedback from the maintainers on whether to implement this as a separate feature or as an extension of the current functionality, and any other suggestions are welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions