Dne čtvrtek, 20. března 2014 20:06:02 UTC+1 Jeremy Evans napsal(a):
>
> I actually just had some time to do so now.  I pushed the changes up to 
> GitHub.  Can you check it and make sure it handles your case correctly?  I 
> can probably release a new gem next week.
>

Okey, this works but it broke creating and deleting not-associated records:

* New associated record - ok
* New not associated record - fails

I, [2014-03-20T20:30:27.722183 #3858]  INFO -- : (0.000268s) BEGIN
E, [2014-03-20T20:30:27.723708 #3858] ERROR -- : 
PG::ObjectNotInPrerequisiteState: ERROR:  record "old" is not assigned yet
DETAIL:  The tuple structure of a not-yet-assigned record is indeterminate.
CONTEXT:  SQL statement "UPDATE "users" SET "redemption_count" = 
"redemption_count" - 1 WHERE "id" = OLD."promo_code_user_id""
PL/pgSQL function 
pgt_cc_users__id__redemption_count__orders__promo_code_user_id() line 6 at 
SQL statement: INSERT INTO "orders" ("user_id", "external_id", "status", 
"meta_data", "book_data", "created_at", "updated_at") VALUES (254, 'TEST', 
20, '{}'::json, '{}'::json, '2014-03-20 20:30:27.722316+0100', '2014-03-20 
20:30:27.722316+0100') RETURNING *
I, [2014-03-20T20:30:27.724187 #3858]  INFO -- : (0.000198s) ROLLBACK
Sequel::DatabaseError: PG::ObjectNotInPrerequisiteState: ERROR:  record 
"old" is not assigned yet
DETAIL:  The tuple structure of a not-yet-assigned record is indeterminate.
CONTEXT:  SQL statement "UPDATE "users" SET "redemption_count" = 
"redemption_count" - 1 WHERE "id" = OLD."promo_code_user_id""
PL/pgSQL function 
pgt_cc_users__id__redemption_count__orders__promo_code_user_id() line 6 at 
SQL statement
from 
/Users/olda/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/gems/sequel-4.8.0/lib/sequel/adapters/postgres.rb:161:in
 
`async_exec'

* Deleting associated record - ok
* Deleting not associated record - fails

E, [2014-03-20T20:33:49.171718 #3858] ERROR -- : 
PG::ObjectNotInPrerequisiteState: ERROR:  record "new" is not assigned yet
DETAIL:  The tuple structure of a not-yet-assigned record is indeterminate.
CONTEXT:  SQL statement "UPDATE "users" SET "redemption_count" = 
"redemption_count" + 1 WHERE "id" = NEW."promo_code_user_id""
PL/pgSQL function 
pgt_cc_users__id__redemption_count__orders__promo_code_user_id() line 3 at 
SQL statement: DELETE FROM "orders" WHERE "id" = 482
Sequel::DatabaseError: PG::ObjectNotInPrerequisiteState: ERROR:  record 
"new" is not assigned yet
DETAIL:  The tuple structure of a not-yet-assigned record is indeterminate.
CONTEXT:  SQL statement "UPDATE "users" SET "redemption_count" = 
"redemption_count" + 1 WHERE "id" = NEW."promo_code_user_id""
PL/pgSQL function 
pgt_cc_users__id__redemption_count__orders__promo_code_user_id() line 3 at 
SQL statement
from 
/Users/olda/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/gems/sequel-4.8.0/lib/sequel/adapters/postgres.rb:161:in
 
`async_exec'

* Updating not associated record (setting some id) - ok
* Updating associated record (setting some id to null) - ok

I almost wrote it works but then I thought I'd rather check unassociated 
records. :-)

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to