title: Datamapper - weird may not be NULL error
body: <p>I'm using DataMapper in a simple application to track sales. I have a <code>Day</code> class, like this:</p>
  
  <pre><code>class Day
  include DataMapper::Resource
  
  property :id,            Serial, :key =&gt; true
  property :date,          DateTime
  property :bestseller,    String
  property :total_money,   Decimal
  property :total_sold,    Integer
  property :total_orders,  Integer
  
  has n, :sales
  
  end
  </code></pre>
  
  <p>and a <code>Sales</code> class:</p>
  
  <pre><code>class Sale
  include DataMapper::Resource
  
  belongs_to :day
  
  property :id,     Serial, :key =&gt; true
  property :name,   String
  property :amount, Integer
  property :value,  Integer
  end
  </code></pre>
  
  <p>When trying to add a new <code>Sale</code> to the database, like so:</p>
  
  <pre><code>s = Sale.new(:day =&gt; Day.get(1), :name =&gt; "Foo", :amount =&gt; "42", :value =&gt; "42"
  </code></pre>
  
  <p>I get this error when calling <code>save</code>.</p>
  
  <pre><code>DataObjects::IntegrityError at /sell
  sales.date may not be NULL
  </code></pre>
  
  <p>I have no <code>date</code> property in <code>Sale</code>, so I'm not sure where this is coming from. First I thought that the <code>Day</code> object I'm getting doesn't have a day set, so I did <code>d = Day.get(1).date = Time.now</code> and <code>save</code>d it, but this doesn't resolve the error.</p>
  
  <p>What did I break?</p>
  
  <p><strong>EDIT</strong> The sqlite3 schema</p>
  
  <pre><code>CREATE TABLE "sales" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 
    "name" VARCHAR(50), 
    "amount" INTEGER,
    "value" INTEGER, 
    "day_id" INTEGER NOT NULL,
    "drink_id" INTEGER NOT NULL
  );
  CREATE INDEX "index_sales_day" ON "sales" ("day_id");
  CREATE INDEX "index_sales_drink" ON "sales" ("drink_id");
  </code></pre>