GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - urbn/sqlkraft: Composable, parameterized SQL statements

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
gradle/wrapper
gradle/wrapper
 
 
lib
lib
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle.kts
settings.gradle.kts
 
 

Repository files navigation

SQLKraft

Composable, parameterized SQL statements

SQL Composition

A sql function that will automatically create parameterized queries from a kotlin string template

Usage

Without Parameters

The following are equivalent and both may be composed with other SqlStatements in the same way

String
val sql = "SELECT * FROM foo"
SqlStatement
val sqlStatement = sql("SELECT * FROM foo")

With Parameters

val sqlStatement = sql("SELECT * FROM foo WHERE id = ${sqlParameter("myFoo")}")

With Nested Statements

val sqlStatement = sql("SELECT * FROM foo WHERE bar_id IN (${createIdSelect()})")

fun createIdSelect() = sql("SELECT id from bar WHERE baz > 10")

WHERE clause

A programatic way to add multiple WHERE clauses without having to worry about WHERE vs AND

val sqlStatement = sql("SELECT * FROM foo ${where("bar > 10", sql("baz = ${SqlParameter("myBaz")}"))}")

SQL Statement Mappers

A set of functions for converting a SqlStatement into the corresponding sql and parameters for different libraries/drivers

Java

    val (sql, parameters) = generateJavaSql(sqlStatement)

Test

    val sqlWithParameters = generateTestSql(sqlStatement)

Publishing

Snapshots

You will need:

  • A maven central account (See https://central.sonatype.org/register/central-portal/)
  • A verified groupId of "com.urbn.nu" (See https://central.sonatype.org/register/namespace/)
  • A GPG Key for signing artifacts (See https://central.sonatype.org/publish/requirements/gpg/)
  • A portal token (See https://central.sonatype.org/publish/generate-portal-token/)

Steps

  1. Ensure version property in lib/build.gradle ends with "-SNAPSHOT"
  2. Setup credentials in $HOME/.gradle/gradle.properties (See below)
  3. Run ./gradlew :lib:publish

Credentials

# GPG Signing
signing.keyId=12345678 # Last 8 digits of GPG key id
signing.password=<insert gpg key passphrase>
signing.secretKeyRingFile=$HOME/.gnupg/secring.gpg

# Maven Central Auth
mavenCentralUsername=<insert portal token username>
mavenCentralPassword=<insert portal token password>

Release

These are the steps to do an official release to maven central. Please test with SNAPSHOT releases before running these steps

Steps

  1. Ensure version property in lib/build.gradle is properly set to next version
  2. Run ./gradlew :lib:publish
  3. Run cd lib/build/repos/releases/
  4. Run tar -czvf gradle-publish-sqlkraft-<insert_version_number>.tar.gz com
  5. Upload tar file using publish portal (See https://central.sonatype.org/publish/publish-portal-upload/)
  6. Tag the current commit and push: git tag -a v<version> -m "Release <version>"

About

Composable, parameterized SQL statements

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.