blythedunham / eload-select Goto Github PK
View Code? Open in Web Editor NEWSelect specific columns with the :select option during eager loading (:include) for ActiveRecord::Base.find
License: MIT License
Select specific columns with the :select option during eager loading (:include) for ActiveRecord::Base.find
License: MIT License
Geokit allows you to make a model mappable through an associated model. So if user is mappable and has lat, lng columns then another model Post can be mappable through user without having lat, lng columns.
So a typical search like User.find(:all, :origin => 'new york, ca', :within => 10) works just fine. but
Post.find(:all, :origin => 'new york, ca', :within => 10) breaks with a long trace.
Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))+, lng))+, posts
.id
AS t0_r0, users
.id
AS t1_r0 FROM posts' at line 4: SELECT _, (ACOS(least(1, COS(0.65877452616526)_COS(-2.13694622955682)_COS(RADIANS(users.lat))_COS(RADIANS(users.lng))+
COS(0.65877452616526)_SIN(-2.13694622955682)_COS(RADIANS(users.lat))_SIN(RADIANS(users.lng))+
SIN(0.65877452616526)_SIN(RADIANS(users.lat))))_3963.19)
AS distance, lng))+, lng))+, posts
.id
AS t0_r0, users
.id
AS t1_r0 FROM posts LEFT OUTER JOIN users
ON users
.id = posts
.user_id WHERE (((users.lat>37.6004301471464 AND users.lat<37.8895698528536 AND users.lng>-122.620827631197 AND users.lng<-122.255172368803)) AND (
(ACOS(least(1,COS(0.65877452616526)_COS(-2.13694622955682)_COS(RADIANS(users.lat))_COS(RADIANS(users.lng))+
COS(0.65877452616526)_SIN(-2.13694622955682)_COS(RADIANS(users.lat))_SIN(RADIANS(users.lng))+
SIN(0.65877452616526)_SIN(RADIANS(users.lat))))_3963.19)
<= 10))
ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))+, lng))+, posts
.id
AS t0_r0, users
.id
AS t1_r0 FROM posts' at line 4: SELECT *, (ACOS(least(1, COS(0.65877452616526)_COS(-2.13694622955682)_COS(RADIANS(users.lat))_COS(RADIANS(users.lng))+
COS(0.65877452616526)_SIN(-2.13694622955682)_COS(RADIANS(users.lat))_SIN(RADIANS(users.lng))+
SIN(0.65877452616526)_SIN(RADIANS(users.lat))))_3963.19)
AS distance, lng))+, lng))+, posts
.id
AS t0_r0, users
.id
AS t1_r0 FROM posts LEFT OUTER JOIN users
ON users
.id = posts
.user_id WHERE (((users.lat>37.6004301471464 AND users.lat<37.8895698528536 AND users.lng>-122.620827631197 AND users.lng<-122.255172368803)) AND (
(ACOS(least(1,COS(0.65877452616526)_COS(-2.13694622955682)_COS(RADIANS(users.lat))_COS(RADIANS(users.lng))+
COS(0.65877452616526)_SIN(-2.13694622955682)_COS(RADIANS(users.lat))_SIN(RADIANS(users.lng))+
SIN(0.65877452616526)_SIN(RADIANS(users.lat))))*3963.19)
<= 10))
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in log' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:323:in
execute_without_analyzer'
from /usr/lib/ruby/gems/1.8/gems/rails-footnotes-3.6.7/lib/rails-footnotes/notes/queries_note.rb:152:in execute' from /usr/lib/ruby/1.8/benchmark.rb:308:in
realtime'
from /usr/lib/ruby/gems/1.8/gems/rails-footnotes-3.6.7/lib/rails-footnotes/notes/queries_note.rb:152:in execute' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:608:in
select'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in select_all_without_query_cache' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in
select_all'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1617:in select_all_rows' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1395:in
find_with_associations'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1393:in catch' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1393:in
find_with_associations'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1546:in find_every' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:615:in
find'
from /home//Apps/nap_on_it/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb:153:in find' from /home//Apps/nap_on_it/config/initializers/geokit_for_named_scope.rb:5:in
find'
from (irb):11>>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.