Skip to content

Major changes in code #4

@enepomnyaschih

Description

@enepomnyaschih

Hi Guillaume

Squiggle is an incredible library that I was looking for. I plan to use it in my future projects. I hate ORM concept and everything that relies too much on magic of reflection. I just need a simple tool to build SQL queries with a standard OOD toolkit.

However, in attempt to use Squiggle I found some major issues that didn't allow me to complete my task. I've decided to tinker into the library and fix these issues. In the result of 2 days of work, it looks like I've reworked the whole code base. See my fork https://github.com/enepomnyaschih/squiggle-sql

I have the following questions:

  • Are you interested in merging this code? I'll open a pull request if you are.
  • If not, should I leave you and Joe Walnes as authors of the code even though 80% of code has been rewritten? Should I choose a different package name and maven artifact name?

Here is the log of changes:

  • Added PreparedStatement compilation support with SQL "?" query parameters. See StatementTest. Just replace MockStatementCompiler with JdbcStatementCompiler are you'll get a real JDBC PreparedStatement to work with.
  • Added conflict-free automated alias generation logic. Call "table.refer()" method to obtain a TableReference - a new alias to use in the query. The queries should be built with TableReferences now, not with Tables. See the updated TutorialTest.
  • Added ResultColumn class returned by addToSelection method. You can use its getIndex method to get the values from the ResultSet by index. You can also use it to order the results by a ResultColumn.
  • Added Literal.of method to build all kinds of supported literals with NullPointerException protection.
  • Added InsertQuery and UpdateQuery.
  • Added TypeCast selectable.
  • Slightly improved implementation of criterias, made it more coincise.
  • Unified and tested CollectionWriter algorithm.
  • Added Java 8 support with its related parameter types (such as java.time.Instant). Left legacy Java 6 version in java6legacy branch.

Here is some work that I plan to do in the future:

  • Escape table/column names that are SQL reserved words.
  • Add possibility to force used-defined table and result aliases to be used (this feature existed in the previous implementation, but I've decided to give alias auto-generation a higher value and priority than maintain this feature).
  • Add more parameter types.
  • Increase test coverage.

Thank you for your time.

Best regards,
Egor.

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