Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viesti/table-spec
Specs from SQL database schema for data generation and validation
https://github.com/viesti/table-spec
clojure spec sql-database-schema
Last synced: 4 months ago
JSON representation
Specs from SQL database schema for data generation and validation
- Host: GitHub
- URL: https://github.com/viesti/table-spec
- Owner: viesti
- License: epl-1.0
- Created: 2017-02-16T20:21:21.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-21T06:30:17.000Z (over 5 years ago)
- Last Synced: 2024-09-28T17:40:55.629Z (4 months ago)
- Topics: clojure, spec, sql-database-schema
- Language: Clojure
- Size: 24.4 KB
- Stars: 35
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# table-spec
[![CircleCI](https://circleci.com/gh/viesti/table-spec/tree/master.svg?style=svg)](https://circleci.com/gh/viesti/table-spec/tree/master) [![Clojars Project](https://img.shields.io/clojars/v/viesti/table-spec.svg)](https://clojars.org/viesti/table-spec)
Specs ([clojure.spec](https://clojure.org/about/spec)) from SQL database schema for data generation and validation.
## Usage
```
> psql
postgres#= create table lol (id int not null, name varchar(250));
CREATE TABLE
``````clojure
...
:dependencies [[org.clojure/clojure "1.9.0-alpha14"]
[viesti/table-spec "0.1.0"]
[org.postgresql/postgresql "9.4.1212"]]
; For generating test data
:profiles {:dev {:dependencies [[org.clojure/test.check "0.9.0" :scope "test"]]}}
...user> (require '[table-spec.core :as t])
nil
user> (require '[clojure.spec :as s])
nil
user> (-> {:connection-uri "jdbc:postgresql:lol" :schema "public"}
(t/tables)
(t/register))
nil
user> (s/exercise :table/lol)
([#:lol{:id -1, :name ""} #:lol{:id -1, :name ""}] [#:lol{:id 0, :name "C"} #:lol{:id 0, :name "C"}]...
user> (s/exercise :lol/id)
([-1 -1] [-1 -1] [1 1] [0 0] [-1 -1] [0 0] [-2 -2] [-1 -1] [-1 -1] [-8 -8])
```# Changelog
### 0.1.1
* Bump to Clojure 1.9.0
* Support smallint, bigint, date, timestamp_with_timezone### 0.1.0
* Initial release
## License
Copyright © 2019 Kimmo Koskinen
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.