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:
- Foster clean and readable code
- Allow for thorough validation of dynamic parts
- Detect as many errors as possible at compile time
- Don't repeat yourself (DRY)
- Allow extension for different SQL dialects
import com.exasol.sql.StatementFactory;
import com.exasol.sql.SqlStatement;
import com.exasol.sql.rendering.SelectRenderer;
SqlStatement statement = StatementFactory.getInstance()
.select().field("firstname", "lastname")
.from().table("person");
String statementText = SqlStatementRenderer.render(statement);
The following sub-sections provide information about building and extending the project.
The list below show all build time dependencies in alphabetical order. Note that except the Maven build tool all required modules are downloaded automatically by Maven.
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 |
Maven JavaDoc Plugin | Creates JavaDoc JARs | Apache License 2.0 |
Maven Source Plugin | Creates source JARs | Apache License 2.0 |
Mockito | Mocking framework | MIT License |
The milestones listed below are a rough outline and might be subject to change depending on which constructs are needed more. The plan will be updated accordingly.
- Basic support for Data Query Language (DQL) statement constructs (SELECT, FROM, JOIN, WHERE)
- Rendering to string
- Exasol Dialect only
- Validation for constructs from M1
(Later milestones will always include validation of the newly learned milestones)
- Scalar functions
- Sub-Selects including validation
- Data Manipulation Language (DML) statements
- Data Definition Language (DDL) statements
- Support for Standard SQL
- Support for other dialects (help welcome!)