Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Spree::UserMethods - add missing table name prefixes within .with_email and .with_email_or_address ActiveRecord scopes

Nathaniel Nande3076e2fee6c3
diff --git a/core/app/models/concerns/spree/user_methods.rb b/core/app/models/concerns/spree/user_methods.rb
index e2bd7eaad9..ed53d7c91e 100644
--- a/core/app/models/concerns/spree/user_methods.rb
+++ b/core/app/models/concerns/spree/user_methods.rb
@@ -31,7 +31,7 @@ module Spree
self.whitelisted_ransackable_attributes = %w[id email]
def self.with_email(query)
- where('email LIKE ?', "%#{query}%")
+ where("#{table_name}.email LIKE ?", "%#{query}%")
end
def self.with_address(query, address = :ship_address)
@@ -42,7 +42,7 @@ module Spree
def self.with_email_or_address(email, address)
left_outer_joins(:addresses).
- where("#{Spree::Address.table_name}.firstname LIKE ? or #{Spree::Address.table_name}.lastname LIKE ? or email LIKE ?",
+ where("#{Spree::Address.table_name}.firstname LIKE ? or #{Spree::Address.table_name}.lastname LIKE ? or #{table_name}.email LIKE ?",
"%#{address}%", "%#{address}%", "%#{email}%")
end
end