elixir-lang/ecto — pull request #129 by jeregrine (2013-12-10 03:00:10+00:00)
Title: Removing nil keys and values from insert cluases

So I ran into this issue, say we have a table:

```sql
CREATE TABLE items( id integer serial, data text, created timestamp default CURRENT_TIMESTAMP)
```

And I have a model
```elixir
defmodule Item do
use Ecto.Model
queryable "items" do
field :data, :string
field :created, :datetime
end
end
```

I and I try to create a new item like so:
```elixir
item = Item.new(data: "hello world!")
Repo.create(item)
```

I expect to get back an item like the following (excuse me if I messed up EctoDate its from memory)
```elixir
[id: 1, data: "Hello World", created: EctoDate[date[year: 2013, month: 12, day: 9], time[hour: 8, min: 25, sec 20]]]
```

Instead I get
```elixir
[id 1, data: "Hello World", created null]
```
Because the ecto postgres adapter here https://github.com/elixir-lang/ecto/blob/master/lib/ecto/adapters/postgres/sql.ex#L75 joins on all of the fields.

My proposed solution is to ignore fields set to NIL on insert and let the database handle that case.

I ran all tests following the contribution guidelines before pushing.