SQL Statement Generation Through AST Translation for Injection Control

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing methods for integrating SQL operations with general-purpose computing languages face challenges such as requiring separate SQL writing, vulnerability to SQL injection attacks, and inability to handle complex database queries effectively.

Innovation Solution

A method that translates database operation instructions expressed in a general-purpose language into SQL statements using an abstract syntax tree, allowing operations to be written entirely in the host language without additional syntax learning, and incorporating a linter for error detection.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of operation

If SQL statements are constructed from string literals in source code, then flexibility in code writing is improved, but security against SQL injection attacks deteriorates

Engineering Contradiction:
Improveflexibility in code writingVSAvoidSQL injection vulnerability
Core Design Contradiction:
Ease of operationVSObject-affected harmful factors

Solution Approach 1:

The patent introduces an intermediary system that sits between the host language code and the SQL execution. This intermediary automatically translates database operation instructions written in the host language into validated SQL statements, preventing direct string concatenation while maintaining flexibility. The intermediary validates and sanitizes all SQL-generated code, eliminating injection vulnerabilities while preserving ease of use.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent replaces the manual mechanical process of constructing SQL strings with automated programmatic translation. Instead of manually concatenating strings to form SQL statements, the system automatically translates high-level database operation instructions into SQL, eliminating the need for vulnerable string manipulation while maintaining coding flexibility.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

2Adaptability or versatility

If embedded query language is implemented, then integration of SQL operations with host language is improved, but device complexity and development control requirements worsen

Engineering Contradiction:
Improveintegration of SQL operationsVSAvoidlanguage implementation complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent extracts the query language implementation complexity from the host language itself. Instead of embedding a full query language interpreter within the host language runtime, the system separates the translation functionality into a standalone component that converts database operation instructions into SQL statements, reducing overall system complexity while maintaining integration capabilities.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent creates a universal translation mechanism that works across different host languages without requiring language-specific implementations. The system translates database operation instructions into SQL in a language-agnostic manner, providing broad adaptability without the complexity of implementing separate embedded query languages for each host language.

Inventive Principle:
Principle #6Universality (Multi-functionality)

3Ease of operation

If object relational mappers are used, then handling of simple CRUD operations is improved, but handling of complex database queries deteriorates

Engineering Contradiction:
Improvehandling of CRUD operationsVSAvoidhandling of complex queries
Core Design Contradiction:
Ease of operationVSAdaptability or versatility

Solution Approach 1:

The patent implements a dynamic translation system that adapts its behavior based on the complexity of the database operation. For simple CRUD operations, it provides automatic translation similar to ORMs. For complex queries, it allows developers to write custom database operation instructions in the host language while still providing automated SQL generation, thus maintaining ease of operation for simple tasks while enabling versatility for complex queries.

Inventive Principle:
Principle #15Dynamics

Data Source

PatentUS12411845B2SQL statement generator
Publication Date: 2025.09.09 SAGE GLOBAL SERVICES LTD
  • US12411845B2 patent drawing
  • US12411845B2 patent drawing
  • US12411845B2 patent drawing

AI summary

A method of generating a SQL statement for performing a database operation. The method comprises: receiving a database operation instruction relating to an operation to be performed on one or more tables of a relational database, said database operation instruction expressed as at least one function in a general-purpose computing language and in which clauses of the database operation instruction are defined in a body of the at least one function; processing the database operation instruction to identify source code associated with the body of the at least one function; generating an abstract syntax tree from the source code, and translating the abstract syntax tree into a SQL statement corresponding to the database operation instruction.