elixir-ecto/ecto_sql
62.8
Adequate · 3 October 2026
15.2k
lines of production code
Elixir
primary language
2
measurements over time
What this system is
This system is EctoSQL, a database integration library for Elixir that manages database connections, migrations, and query execution. It provides adapters for PostgreSQL, MyXQL (MySQL), and Microsoft SQL Server, enabling features like schema migrations, transaction management, and ad-hoc query execution via CLI tasks. The codebase includes comprehensive integration tests and benchmarks to validate adapter-specific behaviors and performance.
How it got here
2018 — MySQL to MyXQL migration and CI modernization
24 changes.
This period focused on replacing the legacy MySQL adapter with MyXQL and introducing support for Microsoft SQL Server via a new TDS adapter. The project also modernized its continuous integration pipeline by migrating from Travis CI to GitHub Actions and Earthly, while expanding test coverage for the new database backends and migration features.
2019–2023 — New adapter support and driver migration
5 changes.
This period focused on expanding database connectivity by introducing a new Microsoft SQL Server adapter and migrating the MySQL adapter from Mariaex to MyXQL. Comprehensive integration test suites were added for both new and updated adapters to validate their specific capabilities and limitations. The underlying test infrastructure was also refactored to ensure compatibility with OTP 26 and modern Ecto patterns.
Features
Introduce Tds adapter for Microsoft SQL Server
Adds a new Ecto adapter for Microsoft SQL Server (TDS), enabling users to connect Ecto applications to MSSQL databases. The implementation includes the connection layer (\lib/ecto/adapters/tds/connection.ex\) for handling query execution and parameter preparation, and a custom UUID type (\lib/ecto/adapters/tds/types.ex\) that ensures correct byte-order conversion for UUIDs stored in the database.
lib/ecto/adapters/tds · high confidence
New \`mix ecto.query\` task and enhanced CLI options for structure and migration tasks
Users can now run ad-hoc queries against the repository using the new \mix ecto.query\ task, which supports \--explain\ to view query plans and \--to-sql\ to inspect generated SQL. Several existing tasks have been updated with new command-line options: \ecto.dump\ and \ecto.load\ now support \--prefix\ for schema-specific dumps and \--skip-if-loaded\ to prevent redundant loads, while \ecto.migrate\, \ecto.rollback\, and \ecto.migrations\ accept \--migrations-path\ to specify custom migration directories. Additionally, \ecto.gen.migration\ now respects the \:migration\_module\ application configuration, allowing users to generate migrations using custom base modules instead of the default \Ecto.Migration\.
lib/mix/tasks · high confidence
Removals
Removal of Ecto SQL integration test cases
The integration test suite located in \integration\_test/cases\ has been removed. This deletion eliminates the test coverage for core Ecto SQL functionalities, including association handling (\assoc\), date and datetime arithmetic (\interval\), various join types (\joins\), record preloading (\preload\), repository operations (\repo\), data type handling (\type\), and database migrations (\migrator\).
_integration\test/cases · high confidence
Behavioural changes
Expanded migration documentation and new migrator API
The \Ecto.Migration\ module documentation has been significantly rewritten to provide a comprehensive guide on creating, running, and formatting migrations, including details on the \schema\_migrations\ table, field types, and the \flush/0\ function. Additionally, \Ecto.Migrator\ now exposes the \with\_repo/3\ function, which allows code to start a repository, execute a function, and terminate it, facilitating migration execution in contexts where Mix is unavailable (such as releases). The \migrations\_path/2\ function has also been updated to accept an optional directory argument for custom migration paths.
lib/ecto · high confidence
Integration test support updated for new types and telemetry changes
The integration test support suite has been updated to align with recent Ecto changes. The \schemas.exs\ and \types.exs\ helper files were removed, consolidating schema definitions into the migration layer. The migration file (\migration.exs\) now includes definitions for new data types such as \:duration\, \:bitstring\, and \:bit\, along with additional fields like \:read\_only\ and \:title\ in existing tables. Furthermore, the repository's telemetry handling in \repo.exs\ was refactored to use \:telemetry.attach\_many\ and updated the event handler signature to include the event name, ensuring compatibility with the latest telemetry API.
_integration\test/support · high confidence
Migrate Ecto MySQL adapter from Mariaex to MyXQL
The MySQL adapter has been switched from the Mariaex driver to the MyXQL driver. This change updates the underlying connection module (renamed from \Ecto.Adapters.MySQL.Connection\ to \Ecto.Adapters.MyXQL.Connection\) and replaces all database interaction calls (such as \query\, \execute\, and \stream\) to use the new MyXQL API. The adapter now enforces that query parameters are lists, adds support for read-only transactions, and improves constraint parsing for unique, foreign key, and check constraint errors to better handle MySQL-specific error messages.
lib/ecto/adapters/myxql · high confidence
Migration API supports CASCADE drop modes and conditional column operations
The migration adapter now allows specifying a drop mode (:restrict or :cascade) for dropping tables, indexes, and constraints, giving users control over whether dependent objects are removed. Additionally, migrations can now add and remove columns conditionally using new :add\_if\_not\_exists and :remove\_if\_exists subcommands, and column types can be specified as binary strings directly. The adapter API also exposes a new dump\_cmd callback for running custom dump CLI commands and removes deprecated timeout options from the execute\_ddl callback.
lib/ecto/adapter · high confidence
Migration runner refactored to use Agent and DynamicSupervisor with enhanced logging and configuration
The migration execution engine has been restructured to replace the dedicated Ecto.Migration.Supervisor with an Agent-based runner managed by a DynamicSupervisor, allowing for more flexible process lifecycle management. This change introduces a new \:log\_migrations\_sql\ option to control DDL logging verbosity, aligning with the broader shift to \--log-migrations-sql\ CLI flags. Additionally, the schema migration module now supports a \:migration\_cast\_version\_column\ option to explicitly cast version types during queries, and exposes the repository instance via a \repo/0\ helper within migrations for easier access to dynamic repo configurations.
lib/ecto/migration · high confidence
Migration to GitHub Actions and Earthly for CI
The project has replaced Travis CI with GitHub Actions workflows and introduced an Earthfile to standardize local and CI test execution. This change updates the continuous integration pipeline to run integration tests for PostgreSQL, MySQL, and MSSQL using Docker containers, ensuring consistent environments across versions. The README has been updated to reflect the new badge and provide instructions for running tests locally via \mix test\ or containerized via \earthly -P +all\.
(repo-wide) · high confidence
MySQL adapter replaced with MyXQL and new TDS adapter added
The legacy \Ecto.Adapters.MySQL\ adapter (which used the Mariaex driver) has been removed and replaced by \Ecto.Adapters.MyXQL\, which uses the MyXQL driver and introduces new options such as \:cli\_protocol\ for CLI tools and \:insert\_mode\ for handling conflict strategies. Additionally, a new \Ecto.Adapters.Tds\ adapter has been added to support Microsoft SQL Server via the TDS protocol, including specific handling for UUIDs, collations, and query hints. The underlying \Ecto.Adapters.SQL\ macro has been refactored to require an explicit \:driver\ option instead of an adapter atom, standardizing how adapters declare their database drivers.
lib/ecto/adapters · high confidence
PostgreSQL adapter: read-only transactions, constraint mapping, and JSON error context
The PostgreSQL adapter now supports read-only transactions via the new \read\_only\_transaction/3\ callback, which sets the transaction to read-only mode before executing the function. Error handling for constraint violations has been updated to map PostgreSQL's \restrict\_violation\ code to the \:foreign\_key\ constraint type, and the \to\_constraints/2\ function signature now accepts an options argument. Additionally, when executing queries that fail with PostgreSQL error code 22P02 (invalid binary representation), the adapter now provides a specific hint suggesting that JSON field parameters may need to be interpolated, helping users debug common JSON query mistakes.
lib/ecto/adapters/postgres · high confidence
Refactor migration path validation and code formatting
The \Mix.EctoSQL\ module has been refactored to improve how migration directories are validated and to align with modern Elixir syntax standards. The \ensure\_started\ function, which previously handled repository startup and logger configuration, has been removed in favor of a new \ensure\_migrations\_paths\ function that specifically validates the existence of configured migration paths. Additionally, the codebase has been updated to use explicit parentheses for nullary static calls (e.g., \Module.split()\, \List.last()\, \Macro.underscore()\, \Mix.Project.deps\_paths()\) and the error message formatting in \raise\_missing\_migrations\ has been adjusted to use the new parenthesized syntax.
lib/mix · high confidence
Sandbox ownership model and adapter callback updates
The SQL adapter sandbox now uses \start\_owner!/2\ and \stop\_owner/1\ to manage connection ownership, replacing the previous \checkout/1\ pattern and enabling better support for dynamic processes and workers. The adapter protocol has been extended with new callbacks including \query\_many/4\ for multi-result queries, \read\_only\_transaction/3\ for read-only transaction support, \explain\_query/4\ for query statistics, and \table\_exists\_query/1\ for table existence checks. Additionally, the \insert/6\ callback now accepts \placeholders\ and \opts\ arguments, and the application supervisor structure has been updated to use \Ecto.MigratorSupervisor\ and \Ecto.Adapters.SQL.StorageSupervisor\ instead of the previous migration supervisor setup.
lib/ecto/adapters/sql · high confidence
Switch MySQL benchmark adapter to MyXQL
The benchmarking infrastructure in bench/support has replaced the Ecto.Adapters.MySQL adapter with Ecto.Adapters.MyXQL. This change updates the repository configuration (Ecto.Bench.MyXQLRepo), adjusts the database URL environment variable to MYXQL\_URL, and modifies the setup script to initialize and migrate the MyXQL repository instead of the previous MySQL one. Additionally, a new helper module (Ecto.Bench.Helper) was added to manage benchmark output paths and formatters, and sensitive connection error data is now explicitly shown for both PostgreSQL and MyXQL repos.
bench/support · high confidence
Switch MySQL benchmarking to MyXQL and add result validation
The benchmark scripts in bench/scripts/macro now use the MyXQL adapter instead of the MySQL adapter for database operations, updating both the read (all\_bench.exs) and write (insert\_bench.exs) benchmarks. Additionally, the all\_bench.exs script now validates that the number of returned results matches the expected limit after each run, and both scripts delegate formatter configuration to a helper module rather than hardcoding JSON file output.
bench/scripts/macro · high confidence
Switch benchmarking from MySQL to MyXQL
The benchmarking setup now uses MyXQL instead of the deprecated Ecto MySQL adapter. This is reflected in the configuration file, which renames the database URL environment variable from MYSQL\_URL to MYXQL\_URL, and in the benchmark helper script, which updates file loading to use require\_file for consistency.
bench · high confidence
Update micro benchmarks to use MyXQL and Stream-based inputs
The micro-benchmark scripts (load\_bench.exs and to\_sql\_bench.exs) have been updated to replace the MySQL adapter with MyXQL, changing the benchmarked jobs from 'MySQL Loader/Query Builder' to 'MyXQL Loader/Query Builder'. Input data generation now uses Stream.map instead of Enum.map to improve memory efficiency, and input labels have been prefixed with numbers for better ordering. Additionally, JSON output configuration has been moved to a helper function (Ecto.Bench.Helper.formatters) rather than being hardcoded in the scripts.
bench/scripts/micro · high confidence
Test coverage
Add MyXQL integration tests; Add TDS adapter integration tests; Added tests for Ecto Mix tasks and updated mock adapters; Expanded Postgres integration test coverage; Expanded SQL integration test coverage for new features and behaviors; Expanded test coverage for Ecto migrations and type handling; Refactor test support infrastructure for OTP 26 and Ecto compatibility; Removed MySQL integration tests; Update EctoSQL tests for Elixir 1.12+ syntax; Updated adapter tests for Ecto 3.8.0-dev and added MyXQL/TDS test suites; Updated test helper file paths.
Dependencies
EctoSQL v3.14.0 release with modernized dependencies and adapter support
This release updates EctoSQL to version 3.14.0, raising the minimum Elixir requirement to 1.15 and replacing the legacy MySQL adapter with MyXQL while adding support for the TDS (MSSQL) adapter. Key dependency upgrades include Ecto (now pulling from the ecto-ecto/ecto git repository), Telemetry (supporting 0.4.0 or 1.0+), DBConnection (upgraded to 2.9+), Postgrex (0.19 or 1.0+), MyXQL (0.8+), and TDS (2.1.1 or 2.2+). The release also updates documentation tooling (ExDoc, makeup\_sql) and benchmarking tools (Benchee suite to 1.0+), and adds a new test alias to verify compilation when EctoSQL is used as a dependency.
(dependencies) · high confidence
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
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 64 → 63 (-0.9)
- Rubric changed (rubric-2026.09.15 → rubric-2026.10.1) — scores are not directly comparable.
Lenses
- Code Health 99 → 99 (+0.0)
- Architecture 66 → 59 (-7.0)
- Maturity 54 → 56 (+2.4)
- Readiness 64 → 67 (+2.6)
- Security 97 → 87 (-9.9)
Resolved (2)
- Off-boarding risk: anonymized user #1
- Orphaned knowledge (integration_test/sql/migration.exs)
New (7)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- Off-boarding risk: anonymized user #1
- Projects may be oversized for their cohesion
Changes since last survey
- 2 commits — 0 feature/other, 2 fixes
By area
- lib/ecto — 2 commits
Notable commits
- fix: Fix invalid postgres SQL related to collation (#756)
- fix: Fix precedence issue in queries, closes #754
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
elixir-ecto/ecto_sql 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 3 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 44f561b824409133abec6f3f356c44ebd2b499cf — the exact code this score is about.
- Scored under rubric-2026.10.1 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-8fe32cd45d00.