com-lihaoyi/scalasql
64.2
Adequate · 20 September 2026
6.8k
lines of production code
Scala
primary language
1
measurement over time
What this system is
ScalaSql is a Scala library that provides a type-safe, functional interface for interacting with relational databases. It supports multiple SQL dialects including PostgreSQL, MySQL, SQLite, H2, and MS SQL, enabling users to construct complex queries with joins, aggregations, and window functions. The system offers a simple case-class-based mapping API and integrates with ZIO for effect-based database operations and transaction management.
Features
Introduce SimpleTable API for case class-based SQL mapping
The \scalasql/simple\ module now provides a \SimpleTable\ API that allows users to map Scala case classes directly to SQL tables without requiring higher-kinded type parameters. This new capability introduces a \Record\ type to represent table rows and a \RecordUpdater\ mechanism for constructing update patches, supported by macro-generated metadata in \SimpleTableMacros\ to handle field reflection and expression walking. The \NamedTupleQueryable\ component enables querying with named tuples, and the \simple.scala\ package object exposes these new types for immediate use.
scalasql/simple · high confidence
Introduce ZIO interop module and core database abstractions
This change adds a new \scalasql-zio\ module that provides a ZIO-native database client (\ZDbClient\) and transaction API (\ZDbTxnApi\), allowing users to execute queries as ZIO effects with automatic error wrapping and resource management. It also introduces a \TransactionListener\ interface in the core \DbApi\ to notify applications of transaction lifecycle events (begin, commit, rollback), and adds a \UseBlock\ abstraction to standardize resource acquisition and release, making the library more friendly to functional programming patterns.
scalasql/core · high confidence
New SQL expression operations and aggregate functions
The \scalasql/operations\ module now provides a comprehensive set of SQL expression builders. Users can perform arithmetic, bitwise, and logical operations on numeric and boolean expressions, as well as string manipulations including concatenation, pattern matching (LIKE), case conversion, and trimming. The module introduces full support for SQL aggregate functions such as COUNT, SUM, AVG, MIN, and MAX, along with window functions like ROW\_NUMBER, RANK, LAG, and LEAD. Additionally, it adds a CASE/WHEN/ELSE expression builder, strict null-safe equality operators (===, !==), and various mathematical functions (trigonometric, logarithmic, hyperbolic).
scalasql/operations · high confidence
New query module with comprehensive SQL query building capabilities
The scalasql/query module introduces a complete set of classes and traits for constructing SQL queries, including SELECT, INSERT, UPDATE, DELETE, and compound operations. Key additions include support for JOINs (including lateral joins for Postgres/MySQL), ON CONFLICT handling, RETURNING clauses, and generated keys retrieval. The module provides a fluent API for building complex queries with filtering, sorting, grouping, and set operations (UNION, INTERSECT, EXCEPT).
scalasql/query · high confidence
Removals
Removal of legacy usql package and core query abstractions
The \usql\ package and its foundational query abstractions have been removed from the source tree. This change deletes \DatabaseApi.scala\, which previously handled raw SQL execution and result set deserialization using upickle, along with \Model.scala\ (defining \Atomic\, \Table\, and \Column\ types), \Query.scala\ (the basic query builder), \Queryable.scala\ (the typeclass for queryable structures), and \ExprIntOps.scala\ (integer expression operations). This cleanup eliminates the initial, simplified query implementation layer in favor of the refactored architecture present in the rest of the codebase.
src · high confidence
Architecture
Migration to Mill 1.0.5 and project restructuring
The build system has been migrated from Mill 0.11.x to Mill 1.0.5, replacing the legacy \build.sc\ with a new \build.mill\ file. This update introduces a multi-module architecture for the ScalaSql library, separating the core functionality into \core\, \query\, and \operations\ submodules, and adding dedicated modules for \scalasql-simple\ (supporting Scala 3.7+ named tuples) and \scalasql-zio\ (ZIO interop). The project now targets Scala 3.6.2 as the primary version, enforces code style via \.scalafmt.conf\, and applies unused-code cleanup through \.scalafix.conf\.
(repo-wide) · high confidence
Behavioural changes
Centralized package exports and convenience utilities in scalasql
The scalasql package now provides a unified entry point that re-exports core components (such as DbClient, Expr, TypeMapper, and Config) and dialect definitions (MySql, Postgres, H2, Sqlite, MsSql) from their respective submodules, simplifying imports for users. Additionally, it introduces convenience utilities including a Bytes type alias and factory methods for geny.Bytes, and a Sc type alias.
scalasql/src · high confidence
Dialect-specific SQL generation and type mapping implementation
The \scalasql/src/dialects\ module now provides concrete implementations for SQL dialects including H2, MS SQL, MySQL, PostgreSQL, and SQLite. This change introduces dialect-specific \TypeMapper\ definitions for standard types (e.g., \Int\, \String\, \UUID\, \LocalDateTime\) and Java/Scala time types, ensuring correct JDBC binding and result set extraction. It also implements dialect-specific SQL rendering logic for operations such as \mkString\ aggregation (using \LISTAGG\, \STRING\_AGG\, \GROUP\_CONCAT\), \SELECT FOR UPDATE\ variants (e.g., \NOWAIT\, \SKIP LOCKED\), \DISTINCT ON\, and \ON CONFLICT\ handling. Additionally, it adds helper classes like \CompoundSelectRendererForceLimit\ and \DbApiQueryOps\ to manage limit/offset rendering and common table expressions (CTEs) within the dialect context.
scalasql/src/dialects · high confidence
Test coverage
Added API and transaction test suites; Added SQL schema and seed data for testing; Added dialect-specific unit tests for H2, MS SQL, MySQL, Postgres, and SQLite; Added example tests for SQL dialects and connection pooling; Added test coverage for SimpleTable with named tuples; Added test coverage for database operations; Added test infrastructure for SQL query validation; Added tests for data type mapping and nullable column handling; Added tests for the ZIO interop layer; Comprehensive test suite for SQL operations across multiple databases; Expanded test coverage for SQL query operations; Removal of legacy test scaffolding and main entry point; Removed test resource file world.sql.
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 64.
Lenses
- Code Health 98
- Architecture 99
- Maturity 60
- Readiness 56
- Security 70
Changes since last survey
- 300 commits — 284 feature/other, 16 fixes
By area
- (root) — 102 commits
- scalasql/src — 57 commits
- scalasql/query — 42 commits
- scalasql/test — 42 commits
- scalasql/core — 17 commits
- docs/design.md — 11 commits
- docs/reference.md — 8 commits
- .github/workflows — 3 commits
- docs/developer.md — 3 commits
- query/src — 3 commits
- scalasql/operations — 3 commits
- (repo) — 2 commits
- docs/tutorial.md — 2 commits
- scalasql/namedtuples — 2 commits
- scalasql/simple — 1 commit
- scalasql/src-2 — 1 commit
- scalasql/zio — 1 commit
Notable commits
- fix: Fix for escaped update with where clause (#79)
- fix: Fix option null values failing to put (#42)
- fix: JoinNullable deserialisation fix (#70)
- fix: bump scala3 version and revert scala3 work around (#66)
- fix: fix publishing
- fix: fix tests
- fix: fix tests after making Values take Queryable
- fix: fix weird type inference around caseClass values.map
- fix: fix-build
- fix: fix-readme
- fix: fix-readme
- fix: fix-readme
- fix: fix-readme
- fix: fix-readme
- fix: fix: remove uneeded Numeric constraint (#47)
- fix: fixes
- change: Enhanced Developer Documentation. Docker Setup and Readability Improvements (#10)
- change: .
- change: .
- change: .
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
com-lihaoyi/scalasql was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 074f1734ccd6dfcd414d3dea0f2b3228e41d5330 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.