On Oct 17, 6:39 pm, Nate Wiger <[email protected]> wrote:
> Jeremy-
>
> Ok, this has taken me way longer than I thought it would, and it's
> because I think I discovered a problem with either (a) the
> MockDatabase/spec structure or (b) the way Sequel works when you try
> to explicitly set a primary key.
>
> I checked in the changes I was working on.  The actual code changes to
> Sequel are literally 2 lines.  But I added some more tests to
> associations_spec because I couldn't get the tests working, and found
> some failures with the primary key being nil in existing tests.  These
> were masked by the tests checking two dynamic values, which were both
> nil:
>
> http://github.com/nateware/sequel/commit/cbed813772fdf82b434e880368c4...
>
> Just run
>
>     spec spec/models/associations_spec.rb
>
> To reproduce.
>
> These don't appear to fail when you're using a primary key that auto-
> increments.  On my local mysql db it appears both the existing API and
> the new patch I added work as expected.

Sequel restricts mass assignment to the primary key fields by default
(though the specs you are using turn that off using
Model.unrestrict_primary_key).

The mocking of the database in the specs takes some getting used to,
admittedly, especially when dealing with saving and loading model
objects from the database (you often have to mock Dataset#fetch_rows
or Model#_refresh).  In many cases, it is easier to write an
integration test first (which use a real database).

I'll look at your branch in a little while and see if I can figure out
what is going wrong.

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to