Hey Jonathan,

The reason this doesn't work is because you're supplying to a
select query an instance object, when it's expecting either column types,
actual values, or some other clause element.  The actual error, I think,
relates to 'type' being your LazyLoader property, and not an actual column! :)

One way to write the query would be to use a proper Clause construct.  You can
see an example of this in the Basic Data Mapping section at:
     
http://www.sqlalchemy.org/docs/index.myt?paged=no#datamapping_relations_lazyload_relselectby
and also at:
    http://www.sqlalchemy.org/docs/index.myt?paged=no#datamapping_selecting

For your case, I imagine it might look like something as simple as:
   myInstance = model.Instance.mapper.select_by(
      instance.c.name == 'primary_email',
      instance_type.c.name == 'email')

Hope that helps!

Cheers!
-G

On Wednesday, April 26, 2006, 2:25:01 AM, you wrote:
> Hi all,

> I've done the svn tutorial as suggested  + gone through the  
> datamapping / advanced data mapping 3x each.

> I seem to be ok on the SELECTs with sqlalchemy, but still having  
> trouble with the writes.

> Specifically I keep running into a wall on this one issue:

> Going back to my example, again its simple, I just can't figure this  
> out based on the docs ( it thought it would have been similar to  
> http://sqlalchemy.org/docs/datamapping.myt#datamapping_onetoone or

> myInstance = model.Instance.mapper.select_by(
>         name = 'primary_email',
>         type = model.InstanceType.mapper.select_by( name = 'email' )
> )

> Trying that, I get
>         AttributeError: 'LazyLoader' object has no attribute 'columns'

> I thought 'maybe I should try it with eager loader or property  
> loader?' same thing.

> ------

> instance_type = Table('instance_type', __engine__,
>      Column('id', Integer, primary_key=True),
>      Column('name', String(255) , unique=instance_type_name_idx' ),
> )
> instance = Table('instance', __engine__,
>      Column('id', Integer, primary_key=True),
>      Column('instance_type_id' , Integer , ForeignKey 
> ("instance_type.id") ),
>      Column('name', String(255) , unique='instance_name_idx' ),
> )

> class Instance(object):
>         pass
> class InstanceType(object):
>         pass

> InstanceType.mapper = mapper( InstanceType , instance_type )
> Instance.mapper = mapper( Instance , instance ,
>         properties = {
>                 'type' : relation( InstanceType.mapper ) ,
>         }
> )
> ----
> i also tried
> ----
> Instance.mapper = mapper( Instance , instance ,
>         properties = {
>                 'type' : relation( mapper(InstanceType , instance_type ) ),
>         }
> )

> ----------

> If anyone can make a suggestion, I'd be grateful.



> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to