Skip to content

Build SQL statements safely without string concatenation

License

Notifications You must be signed in to change notification settings

exasol/sql-statement-builder

Folders and files

NameName
Last commit message
Last commit date
Mar 4, 2021
Oct 12, 2020
Mar 4, 2021
Dec 5, 2019
Mar 4, 2021
Dec 4, 2018
Mar 29, 2019
Sep 18, 2018
Jun 25, 2020
Oct 17, 2018
Oct 17, 2018
Jun 30, 2020
Mar 4, 2021
Mar 4, 2021

Repository files navigation

sql-statement-builder

exasol-testcontainers logo

Build Status Maven Central

SonarCloud results:

Quality Gate Status

Security Rating Reliability Rating Maintainability Rating Technical Debt

Code Smells Coverage Duplicated Lines (%) Lines of Code

The Exasol SQL Statement Builder abstracts programmatic creation of SQL statements and is intended to replace ubiquitous string concatenation solutions which make the code hard to read and are prone to error and security risks.

Goals:

  1. Foster clean and readable code
  2. Allow for thorough validation of dynamic parts
  3. Detect as many errors as possible at compile time
  4. Don't repeat yourself (DRY)
  5. Allow extension for different SQL dialects

In a Nutshell

The following example gives you an idea about what you can do with the SQL Statement Builder. Check our user guide for more details.

final Select select = StatementFactory.getInstance().select() //
        .field("fieldA", "tableA.fieldB", "tableB.*");
select.from().table("schemaA.tableA");
select.limit(10);
final StringRendererConfig config = StringRendererConfig.builder().quoteIdentifiers(true).build();
final SelectRenderer renderer = new SelectRenderer(config);
select.accept(renderer);
final String sql = renderer.render();

Table of Contents

Information for Users

"Users" from the perspective of the sql-statement-builder are developers integrating the module into their own software.

Information for Developers

Dependencies

Test Dependencies

Dependency Purpose License
Apache Maven Build tool Apache License 2.0
Equals Verifier Automatic contract checker for equals() and hash() Apache License 2.0
Hamcrest Advanced matchers for JUnit GNU BSD-3-Clause
JUnit 5 Unit testing framework Eclipse Public License 1.0
Mockito Mocking framework MIT License

Maven Plug-ins

Plug-in Purpose License
Maven Compiler Plugin Setting required Java version Apache License 2.0
Maven GPG Plugin Signs JARs Apache License 2.0
Maven Enforcer Plugin Controlling environment constants Apache License 2.0
Maven Jacoco Plugin Code coverage metering Eclipse Public License 2.0
Maven JavaDoc Plugin Creates JavaDoc JARs Apache License 2.0
Maven Source Plugin Creates source JARs Apache License 2.0
Maven Surefire Plugin Unit testing Apache License 2.0
OFT Maven Plugin Requirement tracing GPL 3.0
Sonatype OSS Index Maven Plugin Checking Dependencies Vulnerability ASL2
Versions Maven Plugin Checking if dependencies updates are available Apache License 2.0