NamedTuples in Action
summary
Demonstrates generating SQL from Scala case classes by borrowing named tuples from Scala 3.7 to get field names and using match types to unwrap Option so navigation through nested optional fields preserves types and produces column paths. Builds a query builder that composes filters, projections, and joins into SQL strings and an implementation called USQL JDBC wrapper that generates inserts and updates, is type safe with autocomplete, is beta and works in practice though it skips aliasing/escaping and hits a Scala compiler bug when deriving one mapping automatically.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 1:50Case classes goals
- 3:36SQL solution limits
- 5:41Named tuples to solve
- 8:10Field navigator with tuples
- 13:32Tracking types in optionals
- 14:15Core SQL types
- 16:25Query builder generation
- 19:37Joins in SQL generation
- 20:46Demo: generated SQL
- 21:28USQL library intro
- 22:53USQL practical example
- 23:13Conclusion and Q&A
related talks
31mGoing structural with Named Tuples
37mTyqu: Typesafe SQL Queries in Scala
52mPolymorphic record types in a lifted enbedding
48mCompositional, Expressive, Performant Database Queries: Choose 3
43mEffective Match Types
49mType level Programming in Scala
38mScalaJS and Typescript: an unlikely romance
44mWriting a Database in Scala.js
