Sroca3 / scrawl

(mirror repo) Scrawl is a sql builder for Microsoft's SQL server

Home Page:https://gitlab.com/sroca3/scrawl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

coverage pipeline

Scrawl

Scrawl is a sql builder for Microsoft SQL Server or at least will start out that way.

Definition

Scrawl - to write (something) in a hurried, careless way.

While hopefully not indicative of the code quality, Scrawl’s name comes from it being a side project that I’m throwing together in my spare time. Also, it’s a cool sounding word.

Origin

Other fuller sql builder implementations already exist such as jOOQ and QueryDsl, but some of my personal experiences pushed me to write my own.

For jOOQ, I didn’t care for the paywall since to adopt such a library you might have to get through the first hurdle of convincing someone else to buy it.

For QueryDsl, I didn’t care for the code generation stance. I much prefer generate once then maintain vs always generate.

Additionally, for both mentioned libraries and more generally with respect to databases, I think trying to generate a common library is a hindrance. SQL languages have to all adhere to a standard first before we can get to that point. Thus, the sql building libraries should be language specific.

Finally, I’ve had too many experiences where an ORM or a sql building library gets in my way, so I wanted to build something thin. Sql building libraries should be like syntactic sugar. If the library gets in the way of generating specific sql statements, then I might as well just use a String.

Dependency Information

Maven

<dependency>
  <groupId>io.github.sroca3</groupId>
  <artifactId>scrawl</artifactId>
  <version>0.2.0</version>
</dependency>

Gradle

implementation 'io.github.sroca3:scrawl:0.2.0'

Usage

Validation Query

// SELECT 1
selectOne().getSql();

Select Queries

// SELECT * FROM Table
select(star()).from("Table").getSql();

The next examples assume you have a class CityTable.

City c = CITY.as("c");
// SELECT c.Name FROM City c
select(c.columns()).from(c).getSql();
var query = select(star()).from(CITY).where(CITY.name().eq("Atlanta"))
// SELECT * FROM City WHERE Name = :name
query.getSql();
// Parameter map: "name" : "Atlanta"
query.getParameterMap();

For other examples, see QueryTest.

About

(mirror repo) Scrawl is a sql builder for Microsoft's SQL server

https://gitlab.com/sroca3/scrawl

License:Apache License 2.0


Languages

Language:Java 99.5%Language:TSQL 0.5%