I’m documenting for myself what I would look for in a validation library. The code I currently need it for is in Kotlin so I have the entire JVM ecosystem to choose from.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openapi: 3.0.0 | |
info: | |
version: 1.0.0 | |
title: Smart City Bikes station protocol | |
paths: {} | |
# No specific paths - one of the events below is either sent via MQTT or pushed via TCP to an IP & port | |
components: | |
schemas: | |
GenericEvent: | |
description: Common properties present in all station events (see individual subtypes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jooq.codegen.GenerationTool | |
// To include into main Gradle file, use: apply(from = "jooq.gradle.kts") | |
val dbHost: String by project | |
val dbPort: String by project | |
val dbName: String by project | |
val dbUser: String by project | |
val dbPass: String by project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaultTasks 'jooqModel' | |
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath "org.postgresql:postgresql:42.1.4" | |
classpath "org.jooq:jooq-meta:3.13.1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select( | |
DIRECTOR.NAME.as(PERSON.NAME), | |
DIRECTOR.ADDRESS.as(PERSON.ADDRESS) | |
) | |
.from(DIRECTOR) | |
.union( | |
select( | |
ACTOR.NAME.as(PERSON.NAME), | |
castNull(PERSON.ADDRESS).as(PERSON.ADDRESS) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jooq.fetchOne("select * from film limit 1"); | |
// type safety for fields | |
jooq.fetchOne("select * from film limit 1").get(FILM.TITLE); | |
jooq.fetchOne("select title || ' ' || description from film limit 1").get(0, String.class); | |
// parameters | |
jooq | |
.fetchOne("select title || ' ' || description from film where title like ? limit 1", "DINOSAUR%") | |
.get(0, String.class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jooq.codegen.GenerationTool | |
import org.jooq.meta.jaxb.* | |
import org.jooq.meta.* | |
// These can also go into gradle.properties | |
def packageName = "my.package" | |
def postgresDriverVersion = "42.1.4" | |
def jooqVersion = "3.11.1" | |
def debugDatabaseHost="localhost" | |
def debugDatabasePort=5432 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jooq.*; | |
import org.jooq.impl.DSL; | |
import java.sql.SQLException; | |
import java.sql.SQLFeatureNotSupportedException; | |
import java.sql.Timestamp; | |
import java.sql.Types; | |
import java.time.Instant; | |
import java.time.OffsetDateTime; | |
import java.time.format.DateTimeFormatter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am gregopet on github. | |
* I am gregorpetrin (https://keybase.io/gregorpetrin) on keybase. | |
* I have a public key whose fingerprint is AF41 B8FB 5C67 F7D5 60FC 3163 70F2 66D4 4ECB A6E6 | |
To claim this, I am signing this object: |
After encountering some shortcomings of named queries I decided to try out Grails' where queries, mainly for their more powerful composition capabilities.
The results were surprising. For the following domain class..
class Bike {
Operator operator
static forOperator(Operator op) {
Bike.where { operator == op }
NewerOlder