My favorites
▼
|
Sign in
substruct
Open-source Ruby on Rails E-Commerce
Project Home
Downloads
Wiki
Issues
Source
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
90
attachment: use_distinct_when_counting_orders.patch
(1.3 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Index: /home/edmundo/workspace_aptana/trunk/vendor/plugins/substruct/app/models/order.rb
===================================================================
--- /home/edmundo/workspace_aptana/trunk/vendor/plugins/substruct/app/models/order.rb (revision 78)
+++ /home/edmundo/workspace_aptana/trunk/vendor/plugins/substruct/app/models/order.rb (working copy)
@@ -100,7 +100,7 @@
# Uses order number, first name, last name
def self.search(search_term, count=false, limit_sql=nil)
if (count == true) then
- sql = "SELECT COUNT(*) "
+ sql = "SELECT COUNT(DISTINCT orders.id) "
else
sql = "SELECT DISTINCT orders.* "
end
@@ -107,12 +107,10 @@
sql << "FROM orders "
sql << "JOIN order_addresses ON orders.order_user_id = order_addresses.order_user_id "
sql << "WHERE orders.order_number = ? "
- sql << "OR order_addresses.first_name LIKE ? "
- sql << "OR order_addresses.last_name LIKE ? "
sql << "OR CONCAT(order_addresses.first_name, ' ', order_addresses.last_name) LIKE ? "
sql << "ORDER BY orders.created_on DESC "
sql << "LIMIT #{limit_sql}" if limit_sql
- arg_arr = [sql, search_term, "%#{search_term}%", "%#{search_term}%", "%#{search_term}%"]
+ arg_arr = [sql, search_term, "%#{search_term}%"]
if (count == true) then
count_by_sql(arg_arr)
else
Powered by
Google Project Hosting