{"id":27391548,"url":"https://github.com/tomsquest/datability","last_synced_at":"2026-05-19T07:36:41.525Z","repository":{"id":35998407,"uuid":"40290608","full_name":"tomsquest/datability","owner":"tomsquest","description":"Drop primary keys, foreign keys, not nulls to let you test insert only the data that matters.","archived":false,"fork":false,"pushed_at":"2016-12-01T09:01:22.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-21T06:10:59.543Z","etag":null,"topics":["database","java","test"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomsquest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-06T07:20:07.000Z","updated_at":"2017-10-11T06:37:06.000Z","dependencies_parsed_at":"2022-08-27T03:15:55.136Z","dependency_job_id":null,"html_url":"https://github.com/tomsquest/datability","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tomsquest/datability","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsquest%2Fdatability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsquest%2Fdatability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsquest%2Fdatability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsquest%2Fdatability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomsquest","download_url":"https://codeload.github.com/tomsquest/datability/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsquest%2Fdatability/sbom","scorecard":{"id":893267,"data":{"date":"2025-08-11","repo":{"name":"github.com/tomsquest/datability","commit":"14be3637e2cf18c3c00a4fb7980411e511f60cab"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-24rp-q3w6-vc56","Warn: Project is vulnerable to: GHSA-r38f-c4h4-hqq2"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T12:41:57.430Z","repository_id":35998407,"created_at":"2025-08-24T12:41:57.430Z","updated_at":"2025-08-24T12:41:57.430Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274152765,"owners_count":25231293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","java","test"],"created_at":"2025-04-13T20:56:33.136Z","updated_at":"2026-05-19T07:36:36.497Z","avatar_url":"https://github.com/tomsquest.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Datability\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.tomsquest/datability/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.tomsquest/datability)\n[![Build Status](https://travis-ci.org/tomsquest/datability.svg?branch=master)](https://travis-ci.org/tomsquest/datability)\n[![codecov.io](https://codecov.io/github/tomsquest/datability/coverage.svg?branch=master)](https://codecov.io/github/tomsquest/datability?branch=master)\n\nTest what matter the most in your Integration test.\n\nDrop primary keys, foreign keys, not nulls to let you test insert only the data that matters.\n\n## Why\n\n**TL;DR**\n\n* Database Constraints are useful in **production**\n* Some integration tests benefit of having constraints disabled\n* Some database engines make this even better: PostgreSQL can rollback `Alter table` and MySql can completely ignore \nthem with `set foreign_key_checks=0`\n\nSeveral years ago, I contracted for a Mobile carrier. The team mission was to remotely configure mobile phone by sending \nbinary SMS for NFC payments. The data model was something like this : a `Phone` has 1-* `SimCard`, a `SimCard` has a `Carrier`, a `Carrier` has 1-* \n`CarrierConfig`, a `SimCard` has 1-* `TransportProtocols`, a `TransportProtocols` has 1-* `ProtocolVersion`... and this continues \nover ~30 tables, all with many foreign keys and not nulls.\n\nInserting a line in one of the child tables was very tedious due to the foreign keys requiring to insert all values until \nthe top of the chain. And all I wanted was to test a complex SQL query on one of these tables. \n\nSo the idea was born : just get rid of these constraints. They are not relevant for my test case.\nEg. Why do I have to insert a `Carrier` when I just require a `SimCard` ? Let me insert a null in `carrier_fk` !.\n\n## Usage\n\nTo use Datability in your test, add it to your pom.xml:\n\n``` xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.tomsquest\u003c/groupId\u003e\n  \u003cartifactId\u003edatability\u003c/artifactId\u003e\n  \u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nThen in java: \n\n``` java\nDatabases.postgresql(connection)\n    .dropNotNulls(\"mytable\", \"anothertable\")\n    .dropPrimaryKeys(\"mytable\", \"anothertable\")\n    .dropForeignKeys(\"mytable\", \"anothertable\")\n    .dropAll(\"yetAnotherTable\"); // drop all not-nulls, primary and foreign keys\n```\n\nFull example using plain Jdbc:\n\n``` java\n// Obtain a Connection from DriverManager or DataSource\nConnection connection = \n    DriverManager.getConnection(\"jdbc:postgresql://host:port/db\", \"user\", \"pass\");\n\n// Let's create a table with a nasty not null\nconnection.createStatement().execute(\"create table mytable (notnullcolumn int not null)\");\n\n// Here the magic happens : drop those constraints !\nDatabases.postgresql(connection)\n    .dropNotNulls(\"mytable\", \"anothertable\")\n    .dropPrimaryKeys(\"mytable\", \"anothertable\")\n    .dropForeignKeys(\"mytable\", \"anothertable\")\n    .dropAll(\"yetAnotherTable\";\n\n// Success: the constraints were removed\nconnection.createStatement()\n    .execute(\"insert into mytable(notnullcolumn) values (null)\");\n```\n\n## Databases support\n\n* [x] PostgreSQL 9.1 to 9.4\n  * [x] Drop not-nulls\n  * [x] Drop primary keys\n  * [x] Drop foreign keys\n  * [x] Drop all constraints (oneliner)\n\n## Hints\n\n### PostgreSQL\n\n* PostgreSQL can rollback DDL statements. Ie. if Datability is called in a Transaction, rollbacking this transaction will\nlet the database unmodified.\n\n* It is not possible to drop not null on primary keys without removing the primary keys first.\nSo first, execute `dropPrimaryKeys()`, then `dropNotNulls()`.\n\n### MySQL\n\nUse `set foreign_key_checks=0` and enjoy testing. \n  \n## Requirements \n\nJava \u003e= 7\n\n## Todo\n\n* Support additional databases\n  * [ ] Oracle\n  * [ ] SqlServer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomsquest%2Fdatability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomsquest%2Fdatability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomsquest%2Fdatability/lists"}