On Nov 19, 2010, at 1:06 PM, Eoghan Murray wrote:

> With a class with 3 primary key columns, e.g.
> 
>    class MyClass(Entity):
>       a = Field(Unicode(64), primary_key=True)
>       b = Field(Unicode(64), primary_key=True)
>       c = Field(Unicode(64), primary_key=True)
>       ...
> 
> If you pass 4 values to query.get;
> 
>    MyClass.get(('a_val', 'b_val', 'c_val', 'd_val'))
> 
> it silently ignores 'd_val' and constructs a query with just a, b and
> c columns.
> I don't think this behaviour is desirable!  It currently throws an
> exception if a 2-tuple is passed to it.
> 
> Fix against trunk attached.

sure thing this is ticket #1977, should be good once tests are added.


> 
> In my case I had inadvertently masked the 'd' column:
> 
>    class MyClass(Entity):
>       a = Field(Unicode(64), primary_key=True)
>       b = Field(Unicode(64), primary_key=True)
>       c = Field(Unicode(64), primary_key=True)
>       d = Field(Unicode(64), primary_key=True)
>       ...
>       d = Field(Unicode(64))
> 
> So that MyClass.table.primary_key.columns only had a, b and c.  Having
> the MyClass.get only accepting 3-tuples would have caught this error.
> Side issue - this example uses elixir - should elixir have caught the
> redeclaration of 'd'?

There's no way elixir could catch that, Python gives you access to the 
just-created class with its final list of attributes.   The original "d" is 
gone.   Unless Elixir kept track of every Field() object created, kept a strong 
reference to it, and then raised "hey there's an extra Field here !", seems 
pretty intrusive overkill to me and a recipe for memory leaks.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to