similar to: Map :join query into model objects

Displaying 20 results from an estimated 30000 matches similar to: "Map :join query into model objects"

2007 Feb 26
24
Ruby/rails port of Cocoon/hibernate
Hi, I''m currently running an apache/jboss cocoon/flow/hibernate/ajax paypal (directpayment) project and am looking into the possibility of porting it across to ruby/rails. For that reason I would like to know the following: 1. Can I call my java classes or would I be looking at a complete rewrite in ruby? 2. How effective is ruby in terms of seperation of concerns regarding design from
2011 Mar 23
1
using R variables in RMySQL query
I have the following function myGetstockdataMySQL <- function(startdate, enddate, ticker) { con <- dbConnect(MySQL(), user="blahblah", password="blahblah", dbname="blahblah", host="localhost") rs <- dbGetQuery(con, "SELECT price.close FROM price INNER JOIN stocks ON stocks.stock_id=price.stock_ID WHERE (price.date_holding BETWEEN
2007 Mar 05
2
SOLVED:Re: How to select postgres for usage instead postgres-pr?
Figured it out chaps..not to worry!!! -- Regards Andrew On 05/03/07, Andrew Madu <andrewmadu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > further to my additional email the gem build for postgres did not work, so > I downloaded and copied postgres.so into: > > C:\pgRails\lib\ruby\site_ruby\1.8\i386-msvcrt > > Again, how do I point rails to using this
2006 May 07
1
Find records not in join with has_many_and_belongs_to
I have a User and Topic model. A user subscribes to a topic, so there is a many-to-many relationship between User and Topic. So my User model object is using has_many_and_belongs_to :topics and vice versa. I want to find all the topics that a user has *not* subscribed to. This is what I''ve got: @user = User.find(params[:id]) @topics = Topic.find(:all, :conditions =>
2011 Sep 05
8
In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL
Hello! Just upgraded to Rails 3.1, ran my test and found this issue: class Trade < ActiveRecord::Base has_many :transaction_trades ..... def Trade.do_something stale_trades = Trade.count(''transaction_trades.id'', :include => :transaction_trades, :group => ''trades.id'')
2008 Jun 13
2
Rails 2.1.0 - find with :include and missing JOIN in SQL query
Hi, We''re trying to rewrite veeeery old Rails app that we successfully managed to move to 1.2.6 and now we''re trying with 2.1.0. One of the problems is caused by :include in AR.find. Rails 1.2.6 generates totally different SQL query than 2.1.0. Here''s Rails find query and generated SQL queries: Foo.find(:all, :include => :ticket, :conditions =>
2006 Jan 22
2
suggest for "ambiguous column" when JOIN associated tables
Today I face with incorrect behavior in ActiveRecord. It take place when I try to use :include parameter for .find method. Where are two typical cases: 1. You have record with self-referential joins CREATE TABLE keywords (id, group_id); class Keyword < ActiveRecord::Base belongs_to :group, :class_name => "Keyword", :foreign_key =>
2009 Feb 19
1
ActiveRecord-2.2.2, association preloading, joins and order parameter weirdness
Hello RoR Groupies, I''m seeing some weird ActiveRecord-2.2.2 SQL generation when doing eager association/preloading and using joins and ordering by said join table. Here''s an example: class Photo < ActiveRecord::Base end class User < ActiveRecord::Base has_one :headshot, :class_name => "Photo" end class Mail < ActiveRecord::Base belongs_to :user end
2006 Jul 15
3
How bad is it to have 7 joins in my find_by_sql?
My question is whether there''s a more idiomatic rails way of structuring this query or of redoing the underlying models. First, the ugly find_by_sql code, which is the method to generate an atom feed: def atom items_per_feed = 15 sql_query = "SELECT activities.*, users.real_name AS real_name, accounts.last_scraped_at AS last_scraped_at,
2009 Aug 07
1
inner joins and outer joins
can anybody guide me on how to create inner joins and left and right outer joins in RoR as both the tables has "has and belongs to many relationships" and there is ajoin table as well
2011 Sep 08
4
In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL
Hello! At first I posted this in rubyonrails-talk, but no one there was able to tell me if this is a bug or not (I got only suggestion for workaround). As this looks like 3.1 regression that breaks existing 3.0.10 code I decided to post this here in addition. I''ve upgraded to Rails 3.1 (from 3.0.10), ran my test suite and found this issue: class Trade < ActiveRecord::Base
2006 Nov 16
3
MySQL query optimization
We have created a Ruby on Rails website which is based on searching a table of 70,000+ object. Each object searched then returns a list of id''s in another table, of about 30,000. The id''s are listed for each object in the first table. The problem is, when we search for object which are very frequently met, the query runs extremely slowly, and after looking at the query log,
2008 Feb 09
0
MVC interplay to query multiple models
I''m trying to track down why I''m getting close to desired output, but not quite. It looks like the webpage sorta-kinda is grabbing the right data. For instance, there are three Login objects which should be showing and it looks like the show is grabbing three objects, so that fits, to a degree. However, it''s just grabbing the hexadecimal object id, and not
2009 Feb 15
3
conditions on association include, hacky but more or less solved
Hi all, I just finally figured out how to get 2.2.2 to do this, and thought I''d share in case others run into the same thing. The situation is a find with associations, but the tricky part is that the association shouldn''t always be loaded. This is similar to putting a condition on a has_many association in a model, but the condition is dynamic rather than predefined. The
2006 Jan 10
0
Day.find_all_with_appointments - INNER JOIN
Hi list, Is there a better/simpler way to code an inner join, than the 4 lines below: class Day < Foo def self.find_all_with_appointments (*args) find :all, { :select => ''distinct foos.*'', :joins => ''INNER JOIN appointments ON days.appointment_id = foos.id'' }.merge
2007 Dec 09
0
straight join in rails
Maybe someone will find this useful: I have a relatively complex (My)SQL query that results from having many many :conditions and :includes, and MySQL seems to apply a wrong join order so I wanted to force an order using the STRAIGHT_JOIN statement, but rails doesn''t really let you do it. Having to construct this query manually (there are 4 joins) and still have a right format for eager
2004 Oct 15
2
combine many .csv files into a single file/data frame
Dear R users, I have a few hundred .csv files which I need to put together (full outer joins on a common variable) to do a factor analysis. Each file may contain anywhere from a few hundred to a few thousand rows. What would be the most efficient way to do this in R? Please include some sample code if applicable. Thank you, b.
2006 Jan 06
0
bug rails activerecord association join
hi, I found a bug in ActiveRecord association SQL INNER JOIN codes. in has_many, has_one, habtm and belongs_to queries the foreign key is determined from the table name of reflection and self. but that''s worng because if you use a global prefix or suffix for your tables the foreign keys will be in format of PREFIX_CLASSNAME_SUFFIX_id which is wrong, because it breaks the advantage of
2006 Apr 10
1
random | in join statement with more than one :include
I have an ActiveRecord class that has several has_many,belongs_to, habtm, and the new has_many => :through relationships. Whenever I try a find(:all, :conditions => "some conds", :include [:relationship]) it works fine, but if I have find(:all, :conditions => "some conds", :include [:relationship, :other_relation]) it gets a sql error such as Mysql::Error: You
2010 Aug 19
1
Composite primary keys and :joins=>
I have a legacy db with the following simplified structure: Table-A: type_key, code_key, name, ... # PKs are type_key and code_key, there is no id col and I cannot alter this db Table-B: # each row has only the code as a foreign_key, the type_key is hard-coded to "FOOKEY" an_id, code, ... Models: class TableB < AR::Base set_table_name ''table_b''