Hi All,
I'm trying to put together an Association Object mapping within a pylons
app, but am getting the following error:
OperationalError: (OperationalError) (1364, "Field 'user_id' doesn't have a
default value") 'INSERT INTO contact_duedate_user_association (contact_id,
modded) VALUES (%s, %s)' (209L, datetime.date(2012, 7, 18))
As far as I can tell I've followed the recomendations in the association
object help and am somehwta stumped as to what is causing the error. The
classes are non-declarative, and are as follows (and if the formatting
holds up the relevant bits should be in bold). Any help enormously
appreciated.
contacts_table = sa.Table('contacts', meta.metadata,
sa.Column('id', sa.types.Integer, primary_key=True),
sa.Column('project_id', sa.types.Integer, sa.ForeignKey('projects.id')),
sa.Column('client_id', sa.types.Integer, sa.ForeignKey('clients.id')),
sa.Column('firstname',sa.types.String(length=255)),
sa.Column('lastname', sa.types.String(length=255)),
sa.Column('email1', sa.types.String(length=255)),
sa.Column('email2', sa.types.String(length=255)),
sa.Column('workphone', sa.types.String(length=255)),
sa.Column('mobile', sa.types.String(length=255)),
sa.Column('company', sa.types.String(length=255)),
sa.Column('category', sa.types.String(length=255)),
sa.Column('job_role', sa.types.String(length=255)),
sa.Column('mailer', sa.types.Boolean),
sa.Column('type', sa.types.Integer), # 0: contact, 1: press
sa.Column('modified', sa.types.DateTime),
)
class ArkContact(object):
def __init__(self):
self.category = 0
self.type = 0
self.modified = datetime.datetime.now()
*#due_contact_association
contact_due_contact = sa.Table('contact_duedate_user_association',
meta.metadata,
sa.Column('contact_id', sa.types.Integer, sa.ForeignKey('contacts.id'),
primary_key = True),
sa.Column('user_id', sa.types.Integer, sa.ForeignKey('users.id'),
primary_key = True),
sa.Column('modded', sa.types.Date)
)
class ArkContactDueDate(object):
def __init__(self):
pass*
*# ArkContactDueDate
orm.mapper(ArkContactDueDate, contact_due_contact, properties={
'contact': orm.relation(ArkContact, backref = 'due_dates')
})*
# ArkUser - users module
orm.mapper(ArkUser, users_table, properties={
'notes': orm.relation(ArkNote,
secondary=user_notes_table,
single_parent=True,
backref='user',
order_by=notes_table.c.date,
cascade="all, delete, delete-orphan"),
'software': orm.relation(ArkSoftware,
secondary=user_software_table,
backref='users'),
'ratings': orm.relation(ArkUserSoftwareRating,
cascade="all, delete",
backref='user'),
'job': orm.relation(ArkJob,
backref='user'),
* 'due_contacts': orm.relation(ArkContactDueDate,
backref = 'due_user',
single_parent=True)*
})
--
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.