AttributeError: 'ColumnProperty' object has no attribute 'strategy'

983 views
Skip to first unread message

lur ibargutxi

unread,
Nov 23, 2007, 11:08:25 AM11/23/07
to sqlal...@googlegroups.com
Hi!

I made an aplication in my local machine but when I tried to do the same in the server I had this problem:

Module Python expression "view.indicators()", line 1, in <expression>
  Module Products.odr.lugabe_db.browser.sql, line 23, in indicators
  Module Products.odr.lugabe_db.query, line 48, in first_group
  Module sqlalchemy.orm.query, line 939, in all
  Module sqlalchemy.orm.query, line 895, in list
  Module sqlalchemy.orm.query, line 964, in __iter__
  Module sqlalchemy.orm.query, line 358, in select_whereclause
  Module sqlalchemy.orm.query, line 1197, in compile
  Module sqlalchemy.orm.interfaces, line 160, in setup
  Module sqlalchemy.orm.interfaces, line 143, in _get_context_strategy
AttributeError: 'ColumnProperty' object has no attribute 'strategy'

Does anyone know about this problem?


--
Lur Ibargutxi
libar...@codesyntax.com

klaus

unread,
Nov 23, 2007, 12:22:06 PM11/23/07
to sqlalchemy
Is it possible that your mapped class has a regular Python property
with the same name as a mapped relation?

Klaus
> libargu...@codesyntax.com

Michael Bayer

unread,
Nov 23, 2007, 12:40:02 PM11/23/07
to sqlal...@googlegroups.com

it means your mappers arent compiling correctly. did you catch an
exception at some point, and then the program continued ? thats
usually what causes that.


lur ibargutxi

unread,
Nov 23, 2007, 12:53:04 PM11/23/07
to sqlal...@googlegroups.com
my problem is that in my local configuration I have SQLAlchemy0.4.0 and collective.lead and my aplication work very well but when i try to do the same thing in the server I have this problem:

ArgumentError: Error determining primary and/or secondary join for relationship ' Areas.idareatype2 (Areatypes)'. If the underlying error cannot be corrected, you should specify the 'primaryjoin' (and 'secondaryjoin', if there is an association table present) keyword arguments to the relation() function (or for backrefs, by specifying the backref using the backref() function with keyword arguments) to explicitly specify the join conditions. Nested error is "Can't find any foreign key relationships between 'areas' and 'areatypes'"


2007/11/23, klaus < klaus.ba...@haufe.de>:

Michael Bayer

unread,
Nov 23, 2007, 2:06:03 PM11/23/07
to sqlal...@googlegroups.com

On Nov 23, 2007, at 12:53 PM, lur ibargutxi wrote:

> my problem is that in my local configuration I have SQLAlchemy0.4.0
> and collective.lead and my aplication work very well but when i try
> to do the same thing in the server I have this problem:
>
> ArgumentError: Error determining primary and/or secondary join for
> relationship ' Areas.idareatype2 (Areatypes)'. If the underlying
> error cannot be corrected, you should specify the 'primaryjoin' (and
> 'secondaryjoin', if there is an association table present) keyword
> arguments to the relation() function (or for backrefs, by specifying
> the backref using the backref() function with keyword arguments) to
> explicitly specify the join conditions. Nested error is "Can't find
> any foreign key relationships between 'areas' and 'areatypes'"
>

ok....using table reflection for your tables (i.e. autoload=True)?
MySQL with MyISAM (the default) tables ? foreign keys won't reflect
in that case, you have to either specify those columns in your Table
defs manually or use InnoDB tables in your MySQL database.

kim

unread,
Oct 4, 2013, 4:10:03 AM10/4/13
to sqlal...@googlegroups.com
T_T

Hi, I am using SQLAlchemy 0.8.2 with PostgreSQL and having exactly same problem.

I have a lot of table classes inherited declarative base and only some of classes raise errors. (https://gist.github.com/yoloseem/d1c9b0f8d3cef6c196e4)

Actually, even for same buggy classes, errors are appeared in some special environment (for me, calling exactly same function works well in web view(Flask) or shell context but always erroneous in Celery task).

To figure out what causes this, I've turn logging level for 'sqlalchemy.orm' to INFO,
and I found some differences between tables working well and error causing tables. (https://gist.github.com/yoloseem/b20cb4a283212ceb0439)
Working things printed out about "_post_configure_properties()" and buggy things printed out about "Identified primary key columns".

please somebody help me? !!


2007년 11월 24일 토요일 오전 4시 6분 3초 UTC+9, Michael Bayer 님의 말:

Michael Bayer

unread,
Oct 4, 2013, 9:59:33 AM10/4/13
to sqlal...@googlegroups.com

this is definitely not related to any issue from 2007.   See what happens if you call sqlalchemy.orm.configure_mappers() right before you emit that Query in this particular test.    the error indicates this particular class was not present when the mappers post-configured themselves.


--
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 sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

signature.asc

Hyunjun Kim

unread,
Oct 6, 2013, 12:22:04 AM10/6/13
to sqlal...@googlegroups.com
oh sorry. I thought the subject duplication shouldn't be in the mailing list.

I called configure_mappers() right before every query execution, but it does not work still.

even one of erroneous class has only single column in table and has no foreign keys or dynamical integration between any other stuffs.

how can i fix this?

김현준 드림
-
Hyunjun Kim
StyleShare Inc. | Software Engineer
Sent with Sparrow

Hyunjun Kim

unread,
Oct 6, 2013, 12:39:13 AM10/6/13
to sqlal...@googlegroups.com
oh, i fixed the problem. your explanation was exactly right. most of tables do not seem to have any relation to errors so it was hard to find the error.

i have a dynamic module 'm' that is implemented to contain all ORM models for convenience. one of relationship property referencing another table via module m, and it twisted all when sqlalchemy configured all classes.

thank you for help!! 

On 2013년 10월 6일 Sunday at 오후 1:22, Hyunjun Kim wrote:

oh sorry. I thought the subject duplication shouldn't be in the mailing list.

I called configure_mappers() right before every query execution, but it does not work still.

even one of erroneous class has only single column in table and has no foreign keys or dynamical integration between any other stuffs.

how can i fix this?

Michael Bayer

unread,
Oct 6, 2013, 11:51:11 AM10/6/13
to sqlal...@googlegroups.com
you'd need to send a fully self-contained code example that reproduces the issue.   the gists you have don't show any code.
signature.asc
Reply all
Reply to author
Forward
0 new messages