On Jan 31, 2006, at 4:57 PM, Michael Bayer wrote:

Ok youve got this:

  dt = DesignType.select()[0]

is there a row, and dt non-None ?

  d = Design(type=dt)

The auto-constructor thing *should* be working, do you get something back
for d.type ?  does dt.designs have something in it ?


>>> len(dt.designs)
167

>>> d.type is dt
True

>>> d.id is None
True

>>> [d2 for d2 in dt.designs if d2.id is None]
[]


Does that answer your questions?

Thanks,
~ Daniel

Here's a bit more debug output (note there are actually two more columns which I omitted in the original example to reduce the noise):

>>> d = Design(type=dt, name="test", amount=23.0)
>>> objectstore.commit()
select nextval('design_id_seq')
{}
INSERT INTO design (id, design_type_id, name, amount) VALUES (%(id)s, %(design_type_id)s, %(name)s, %(amount)s)
{'design_type_id': None, 'amount': 23.0, 'id': 412L, 'name': 'test'}

psycopg.IntegrityError Traceback (most recent call last)

/Users/dmiller/Code/PyOE/src/<console>

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/mapping/objectstore.py in commit(*obj) 66 since that begin statement. otherwise commits all objects that have been
     67     changed."""
---> 68     uow().commit(*obj)
     69
     70 def clear():

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/mapping/objectstore.py in commit(self, *objects)
    291             e.begin()
    292         try:
--> 293             commit_context.execute(echo=echo_commit)
    294         except:
    295             for e in engines:

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/mapping/objectstore.py in execute(self, echo)
    397                 print "Task dump:\n" + head.dump()
    398         if head is not None:
--> 399             head.execute(self)
    400         if LOG or echo:
    401             if head is not None:

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/mapping/objectstore.py in execute(self, trans)
    551             dep.execute(trans, delete=True)
    552         for child in self.childtasks:
--> 553             child.execute(trans)
    554         for element in self.todelete_elements():
    555             if element.childtask is not None:

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/mapping/objectstore.py in execute(self, trans)
    542             return
    543
--> 544         self.mapper.save_obj(self.tosave_objects(), trans)
    545         for dep in self.save_dependencies():
    546             dep.execute(trans, delete=False)

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/mapping/mapper.py in save_obj(self, objects, uow)
    570                 for rec in insert:
    571                     (obj, params) = rec
--> 572                     statement.execute(**params)
573 primary_key = table.engine.last_inserted_ids()
    574                     if primary_key is not None:

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/sql.py in execute(self, *multiparams, **params)
    394             bindparams = params
    395         c = self.compile(e, parameters=bindparams)
--> 396         return c.execute(*multiparams, **params)
    397
    398     def scalar(self, *multiparams, **params):

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/sql.py in execute(self, *multiparams, **params)
    288             params = multiparams
    289
--> 290         return self.engine.execute_compiled(self, params)
    291
    292     def scalar(self, *multiparams, **params):

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/engine.py in execute_compiled(self, compiled, parameters, connection, cursor, echo, **kwargs)
    531         self.pre_exec(proxy, compiled, parameters, **kwargs)
532 self._process_defaults(proxy, compiled, parameters, **kwargs)
--> 533         proxy(str(compiled), parameters)
    534         self.post_exec(proxy, compiled, parameters, **kwargs)
535 return ResultProxy(cursor, self, typemap=compiled.typemap)

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/engine.py in proxy(statement, parameters)
    526                     parameters = parameters.values()
    527
--> 528 self.execute(statement, parameters, connection=connection, cursor=cursor)
    529             return cursor
    530

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/engine.py in execute(self, statement, parameters, connection, cursor, echo, typemap, commit, **kwargs) 580 self._executemany(cursor, statement, parameters)
    581             else:
--> 582                 self._execute(cursor, statement, parameters)
    583             if self.context.transaction is None:
    584                 self.do_commit(connection)

/Library/Python/2.3/site-packages/SQLAlchemy-0.91alpha-py2.3.egg/ sqlalchemy/engine.py in _execute(self, c, statement, parameters)
    590     def _execute(self, c, statement, parameters):
    591         #try:
--> 592         c.execute(statement, parameters)
    593         #except:
594 # raise "OK ERROR " + statement + " " + repr (parameters)

IntegrityError: null value in column "design_type_id" violates not- null constraint


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to