dresende/node-orm2 — pull request #318 by dxg (2013-08-28 11:06:13+00:00)
Title: Properties refactor

To fix #310 I needed a way to reliably pass a model property to a DML drivers `valueToProperty` method from within an `Instance`.
Since some properties were set on `Model.properties` whilst others like ids & association fields existed only in an array of strings (and their types were inferred by the drivers DDL `sync` code) this made life difficult.
It also introduced duplicate code, and issues with redefining key columns, and no good way to specify exact types for ALL columns.

I've come up with `Model.allProperties` which stores definitions of all constant properties (normal properties, id props, association fields). Extra properties remain separate as they are transient.

This allowed for some nice code cleanups in driver `sync` methods, and a simplification of `opts.data` initialization code inside `Instance`.

It also fixes some inconsistent behaviour I found along the way, like `Model.create` casting properties when they are set and `instance.save` not doing so.

Lastly, it introduces a new syntax (only internally for now) for defining keys, as discussed in #313 :
```js
var Person = db.define("person", {
id: { type: 'serial', key: true },
name: { type: 'text' }
});
```
Composite keys:
```js
var Person = db.define("person", {
firstname: { type: 'text', key: true},
lastname: { type: 'text', key: true}
});
```

Keys are currently still set via the `id` property, however now that the underlying work is done, we can change this in future to the `key` syntax without too much pain.

**Note**: We now have both `Model.allProperties` and `Model.properties`. It should be possible to remove the latter in the future. It was taking me forever to finish this refactor, so consider this code a transition step.

@dresende the failing tests depend on sql-query 0.11.12 being published - the change in sql-query is small.