Max Ischenko wrote:
> Hello,
>
> I'm struggling with a simple one to many relation, pls help!
>
>
> active_meetup = MeetupEvent(...)
> reg = MeetupRegistration(meeting=active_meetup)
>
> db.save(reg)
>
> *<class 'sqlalchemy.exceptions.OperationalError'>: (OperationalError)
> (1048, "Column 'meeting_id' cannot be null") u'INSERT INTO
> dou_meetup_registrants (meeting_id, name, email, phone) VALUES (%s, %s,
> %s, %s)' [None, u'1.0', u'[EMAIL PROTECTED]
> <mailto:u'[EMAIL PROTECTED]>', u'+38 063 2061046']*
>
> Obviously SA somehow can't find meeting_id even thou reg.meeting is OK.
The mapped backref is 'meetup' but the class's __init__ is setting
'meeting':
> mapper(MeetupEvent, dou_meetups_tbl, properties={
> 'registrants':relation(MeetupRegistration, backref='meetup'),
> })
> [snip]
>
> class MeetupRegistration(object):
> def __init__(self, meeting, name=None, email=None, phone=None):
> if not meeting:
> raise ValueError("Meeting event not set")
> if not email:
> raise ValueError("Email is required")
> self.meeting = meeting
> self.name = name
> self.email = email
> self.phone = phone
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---