Permalink
Browse files

Updated project, readme, roadmap and history files for the 0.5.0 rele…

…ase.
  • Loading branch information...
1 parent 37e209f commit fc354d2ec49d7817948768dd846b4f56f29c972b @budu budu committed Jan 9, 2011
Showing with 102 additions and 25 deletions.
  1. +7 −0 history.md
  2. +3 −3 project.clj
  3. +91 −18 readme.md
  4. +1 −4 roadmap.md
View
@@ -1,5 +1,12 @@
# Lobos History
+## 0.5
+
+ * Added remaining scalar data-types
+ * Added support for foreign key and check constraints
+ * Rewrote part of the analyzer as a multi-method
+ * Added drop cascade support for SQL Server
+
## 0.4
* Added a comprehensive set of data types
View
@@ -1,9 +1,9 @@
-(defproject lobos "0.5.0-SNAPSHOT"
+(defproject lobos "0.5.0"
:description
"A library to create and manipulate SQL database schemas."
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[clojureql "1.0.0"]]
:dev-dependencies [[swank-clojure "1.2.1"]
- [clj-help "0.2.0"]
- [com.h2database/h2 "1.2.147"]])
+ [lein-clojars "0.6.0"]
+ [clj-help "0.2.0"]])
View
109 readme.md
@@ -7,28 +7,31 @@ handled by the [new ClojureQL] project. It aims to add higher-level
features like declarative schema manipulation and built-in migration
support.
-This is currently a very early release, use at your own risk. You can
-have a look at the [roadmap] for more information about future releases
-and consult the [history] to see what have been done.
+This is currently an early release, use at your own risk. You can have a
+look at the [roadmap] for more information about future releases and
+consult the [history] to see what have been done.
+
+Lobos supports H2, MySQL, PostgreSQL, SQLite and SQL Server. You'll need
+to add the relevant JDBC driver manually.
## Usage
-There's a quick overview of how it works in its current state below, but
-take note that not much has been done yet. Lobos currently supports H2,
-MySQL, PostgreSQL, SQLite and SQL Server.
+Here's a quick overview of how it works in its current state.
+
+### Basics
First you'll need to use at least the following namespaces:
(use 'lobos.connectivity
'lobos.core
'lobos.schema)
-You'll also need to use the namespace corresponding to the database
-you're using:
+You'll also need to include the namespace corresponding to the database
+you want to communicate with:
(use 'lobos.backends.postgresql)
-Then you'll need a connection, the following example define a test
+Then you'll need a connection. The following example define a test
connection and makes it the default global connection:
(def db
@@ -40,42 +43,111 @@ connection and makes it the default global connection:
(open-global db)
-You can send DDL statement directly to a connected database like this:
+You can send DDL statements (called actions) directly to a connected
+database like this:
user> (create db (table :users (integer :id :unique)))
nil
- user> (drop db (table :users (integer :id :unique)))
+
+You can omit the connection altogether and the actions will use the
+default one.
+
+ user> (drop (table :users (integer :id :unique)))
+ nil
+
+### More Complex Example
+
+Lobos now supports a quite comprehensive set of features for creating
+tables, here's a more complex example:
+
+ user> (create (table :users
+ (integer :id :auto-inc :primary-key)
+ (varchar :name 100 :unique)
+ (integer :age)
+ (timestamp :created_on [:default :current_timestamp])
+ (check :old-enough (> :age 18))
+ (check :not-too-old (< :age 118))))
+
+ user> (create (table :posts
+ (integer :id :auto-inc :primary-key)
+ (varchar :title 200 :unique)
+ (clob :content)
+ (timestamp :created-on [:default :current_timestamp])
+ (integer :user_id)
+ (foreign-key [:user_id] :users [:id])))
+
+The `drop` action has the optional `behavior` parameter that works even
+on database without built-in support for it:
+
+ user> (drop sqlserver-spec (table :users) :cascade)
nil
+
+### Schemas
-Or use a schema which you'll first need to define:
+You can use a schema which you'll first need to define:
(defschema sample-schema :public)
-And you also make a schema a default one:
+Then you can make that schema the default one:
(set-default-schema sample-schema)
-Now you can send DDL statement to the database to which the schema is
-attached:
+Now you can call actions on the database to which the schema is attached
+and the actions will return the schema definition instead of nil:
user> (create (table :users (integer :id :unique)))
#:lobos.schema.Schema{...}
user> (drop (table :users))
#:lobos.schema.Schema{...}
+### Debugging
+
You can always set the debug level to see the compiled statement:
user> (set-debug-level :sql)
:sql
user> (create (table :users (integer :id :unique)))
CREATE TABLE "lobos"."users" ("id" INTEGER, CONSTRAINT "unique_id" UNIQUE ("id"))
-As you can see Lobos use delimited and schema qualified identifiers.
+As you can see Lobos use delimited identifiers by default and schema
+qualified identifiers when an action use a schema.
+
+### Analyzer
+
+Lobos includes a database analyzer which use the database meta-data to
+construct an abstract schema definition from an actual database
+schema. This feature is only experimental for the moment and is used
+internally to update the global schema map and for integration testing.
+You can try it out like that:
+
+ user> (use 'lobos.analyzer)
+ nil
+ user> (analyze-schema :test)
+ #:lobos.schema.Schema{...}
+ user> (-> :test analyze-schema :elements :users :columns :name)
+ #:lobos.schema.Column{...}
+ user> (-> :test analyze-schema :elements :posts :constraints :posts_fkey_user_id)
+ #:lobos.schema.ForeignKeyConstraint{...}
+
+This feature may eventually be split into its own project and is quite
+limited in its current form. Currently it doesn't support check
+constraints and need a custom JDBC driver for [SQLite].
## Installation
-For now the only way to install Lobos is to clone the repository and
-compile it yourself.
+Lobos is available through Clojars.
+
+For the latest release, in Cake/Leiningen:
+
+ [lobos "0.5.0"]
+
+in Maven:
+
+ <dependency>
+ <groupId>lobos</groupId>
+ <artifactId>lobos</artifactId>
+ <version>0.5.0</version>
+ </dependency>
## License
@@ -88,3 +160,4 @@ the file epl-v10.html in the project root directory.
[new ClojureQL]: https://github.com/LauJensen/clojureql
[roadmap]: https://github.com/budu/lobos/blob/master/roadmap.md
[history]: https://github.com/budu/lobos/blob/master/history.md
+[SQLite]: https://github.com/budu/sqlitejdbc
View
@@ -11,7 +11,4 @@
## 0.6
* Support for altering tables
-
-## 0.5
-
- * Analyzer rewrite, will probably change the compiler multi-method
+ * Adding functional testing

0 comments on commit fc354d2

Please sign in to comment.