public
Rubygem
Description: DataMapper - Core
Homepage: http://datamapper.org
Clone URL: git://github.com/sam/dm-core.git
Search Repo:
Merge branch 'field_name'
myobie (author)
Thu May 08 12:15:35 -0700 2008
commit  b9b7d439a77abcad5ea177e879e13ff7f35b1150
tree    ffe01e698e752444b34bd7f51d08b04845ef96c4
parent  52ec354b3bd0cbef118ccc59aee12affa7a13277 parent  24c46588a0b88b6688bf871c086b9602d19f516c
...
536
537
538
539
540
 
 
541
542
543
...
536
537
538
 
 
539
540
541
542
543
0
@@ -536,8 +536,8 @@
0
           unless query.order.empty?
0
             parts = []
0
             query.order.each do |item|
0
- parts << item.name if DataMapper::Property === item
0
- parts << "#{item.property.name} #{item.direction}" if DataMapper::Query::Direction === item
0
+ parts << item.field if DataMapper::Property === item
0
+ parts << "#{item.property.field} #{item.direction}" if DataMapper::Query::Direction === item
0
             end
0
             sql << " ORDER BY #{parts.join(', ')}"
0
           end
...
237
238
239
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
241
242
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
0
@@ -237,6 +237,21 @@
0
         other = DataMapper::Query.new(repository(:mock), Article, :order => order)
0
         @query.update(other).order.should == order
0
       end
0
+
0
+ it "#order with a property that uses :field => something" do
0
+ class Article
0
+ property :plank, String, :field => 'real_plank'
0
+ end
0
+
0
+ query = DataMapper::Query.new(repository(:mock), Article, :order => [:plank.desc])
0
+
0
+ query.order.first.property.should == Article.properties[:plank]
0
+ query.order.first.property.field.should == 'real_plank'
0
+ query.order.first.direction.should == :desc
0
+
0
+ # this is the real test here, I can't find any other way to make it parse the order into sql than to run the whole query through
0
+ repository(:mock).adapter.query_read_statement(query).should == %Q{SELECT "id", "blog_id", "created_at", "author", "title" FROM "articles" ORDER BY real_plank desc}
0
+ end
0
 
0
       # dkubb: I am not sure i understand the intent here. link now needs to be
0
       # a DM::Assoc::Relationship or the name (Symbol or String) of an

Comments

    No one has commented yet.