CONTRIBUTING
Contributing
Thanks for your interest in ORM::ActiveRecord. This guide covers how to get set up, run the tests, and match the conventions the codebase already follows.
Getting set up
Install the dependencies:
zef install --deps-only .The tests run against PostgreSQL, MySQL, and SQLite. SQLite needs no setup. For
PostgreSQL and MySQL, create the databases and point the test environment at
them in config/application.json (see Adapters for
the config shape). You can also override the primary connection with
DATABASE_URL.
Create and migrate the configured databases:
raku -Ilib bin/active-record createdb
raku -Ilib bin/active-record migrateRunning the tests
test.raku is the entry point. It runs the t/ suite (via prove6) and the
specs/ suite (via behave).
A bare ./test.raku runs only the adapter named in config/application.json
(the test.primary.adapter key), at the worker count from test.parallel. It
does not probe the other two adapters. To run more than one adapter, name them
explicitly with --adapter:
./test.raku # only the configured adapter (test.primary.adapter)
./test.raku --adapter=pg,mysql,sqlite # all three, probing each
./test.raku --adapter=sqlite # one specific adapter
./test.raku --prove6 # only the t/ suite
./test.raku --behave # only the specs/ suite
./test.raku --all # once per config/application.json-*-exampleWhen --adapter names an adapter your config does not define, that adapter
falls back to its default connection URL (or its AR_*_URL env var), not to
your config, so it may skip if unreachable. --all ignores config/application.json
entirely: it swaps each config/application.json-*-example into place in turn,
backing up and restoring your real config around the run.
Run a single file while iterating:
prove6 -Ilib t/validation/length.rakutest
behave specs/validation/length-spec.rakuAfter editing a library module, clear stale precompilation if behave's bulk discovery starts failing:
rm -rf lib/.precompConventions
t/ and specs/ mirror each other
Every test in t/ (Test / prove6) has a counterpart in specs/
(BDD::Behave), and vice versa. Shared setup code lives under specs/lib/. When
you change behaviour, update both sides in the same commit.
Register new modules in META6.json
When you add a lib/**/*.rakumod, add it to the provides section in the same
step. prove6 -Ilib resolves by path and won't catch a missing entry, but zef
and the metadata test will.
Migrations
Migration files are db/migrate/NNN-kebab-name.raku with a zero-padded numeric
prefix. Generated migrations use a timestamp prefix instead. Avoid MySQL
reserved words in table and column names ā the DDL emitter does not quote
identifiers.
Documentation
User-facing docs live under docs-src/docs/ and are wired into
docs-src/mkdocs.yml. When a change adds a feature or changes behaviour, update
the matching page in the same commit; the docs should track the specs/.
Code style
Separate logical chunks with blank lines.
Use descriptive names, even in small scopes.
Keep comments short and factual; prefer a test over a comment.
Method names cannot end in
!or?: portsave!tosave-bangandvalid?tois-valid. Underscores become hyphens.
Submitting changes
Branch from
main.Make your change with tests on both the
t/andspecs/sides.Run
./test.rakuand make sure it passes.Update the docs and
CHANGELOG.mdunder[Unreleased].Open a pull request describing the change and why.
Reporting issues
Open an issue with the adapter and version, a minimal model and migration that
reproduces the problem, and the SQL or error you see (set DISABLE-SQL-LOG
unset to view the SQL).