On Wednesday, June 12, 2013 7:52:27 AM UTC-7, Charlie Clark wrote:
>
> Am 11.06.2013, 23:47 Uhr, schrieb Andy <[email protected] <javascript:>>: 
>
> > I could do that, but I'd change the foreign key in favorites to point at 
> > group_things, since your favorite group must be a group that you're in. 
> > Then I'd drop the other foreign key constraint as unnecessary, since 
> it's 
> > implied by the new one, and then I'd be back at square one (needing to 
> > convince the ORM to understand a relation with no real foreign key). 
>
> Ah, okay. I think I understand what I was missing initially. I've had   
> another go at this and it seems to work as required, even on MySQL.  Not   
> sure how this all works with SQLAlchemy but I would expect it to be fine   
> with it. 
>
> insert into favourites (thing_id, group_id) values (2, 2) 
> Error Code: 1062. Duplicate entry '2' for key 'PRIMARY'        0.012 sec 
>
> insert into favourites (thing_id, group_id) values (1, 3) 
> Error Code: 1452. Cannot add or update a child row: a foreign key   
> constraint fails ("favourites"."favourites", CONSTRAINT "checker" FOREIGN 
>   
> KEY ("thing_id", "group_id") REFERENCES "groups_things" ("thing_id",   
> "group_id"))        0.007 sec 
>

It's not, at least with automatically configured relations, hence this 
thread.
 

>
> > Also, SERIAL?  You must be using a real database engine. 
>
> Well, er, yes. When it comes to modelling that's where you should start.   
> And Oracle is making progress with MySQL now that InnoDB with separate   
> files pro table and 5.6 even seems to have some kind of vacuuming 
> built-in. 
>

I dunno.  This may be the end of my (nonexistent) web developer career, but 
I think I will never again recommend using mysql for any purpose whatsoever 
(except perhaps compatibility).  I've learned my lesson.  Next time I'll 
use PostgreSQL. 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to