Ticket #108 (accepted defect)
order_by in OneToMany fails if colname is specified on target field
| Reported by: | guest | Owned by: | ged |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | core | Version: | 0.7.1 |
| Keywords: | Cc: |
Description
By my reading of the OneToMany docs, the order_by parameter refers to the Field in the target class used to order the results of this collection. "order_by: Specify which field(s) should be used to sort the results given by accessing the relation field."
However, when attempting to implement this behavior, I found that specifying the field name results in an Exception, "no column found", during setup of the Entities. A runnable failing example is attached. The traceback it outputs follows this report.
I suspect that either the order_by parameter should accept field names or the documentation should be updated to reflect that column names must be specified (certainly less desirable).
python .\elixir_order_by.py
Traceback (most recent call last):
File ".\elixir_order_by.py", line 21, in
<module>
setup_all(True)
File "C:\Python\lib\site-packages\elixir-0.7.1-py2.6.egg\elixir\init.py",
line 94, in setup_all
setup_entities(entities)
File "C:\Python\lib\site-packages\elixir-0.7.1-py2.6.egg\elixir\entity.py", line 951, in setup_entities
method()
File "C:\Python\lib\site-packages\elixir-0.7.1-py2.6.egg\elixir\entity.py", line 469, in setup_properties
self.call_builders('create_properties')
File "C:\Python\lib\site-packages\elixir-0.7.1-py2.6.egg\elixir\entity.py", line 481, in call_builders
getattr(builder, what)()
File "C:\Python\lib\site-packages\elixir-0.7.1-py2.6.egg\elixir\relationships.py", line 466, in create_properties
self.target._descriptor.translate_order_by(kwargsorder_by?)
File "C:\Python\lib\site-packages\elixir-0.7.1-py2.6.egg\elixir\entity.py", line 373, in translate_order_by
col = self.get_column(colname.strip('-'))
File "C:\Python\lib\site-packages\elixir-0.7.1-py2.6.egg\elixir\entity.py", line 558, in get_column
% (key, self.entity.name))
Exception: No column named 'position' found in the table of the 'Bullet' entity!
