Displaying 20 results from an estimated 10000 matches similar to: "Arel: misunderstanding with intersections"
2011 Apr 10
0
Arel Union does not support #order or #limit
I just posted this ticket in Lighthouse, but thought perhaps some
discussion here would help point me in the right direction toward a
solution. Here is a description of the problem (from the ticket - https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6693-arel-union-does-not-support-order-or-limit)
:
> If we take two `ActiveRecord::Relations` and join them via `union`:
2010 May 12
0
OT? Using Arel to generate table names in multiple self join query
Firstly I''m sorry if this is off-topic but I think it''s a question
that won''t be answered without good core knowledge.
I have written a multiple self join query something like this:
Person.find :all,
:select => ''children_people_3.*'',
:joins => { :children => { :children => :children } },
:conditions => {
:people => { :name
2012 Dec 18
1
Arel limit Where if fields are present
I trying to create a select using Arel but I''m passing three parameters, I
want to include the parameters only if they are different to nil or blank.
Here is my method:
def self.advsearch(summary_description, specialties, place)
User.joins(:experience,:summary,:information)
.where(Information.arel_table[:business].eq(false))
2006 Apr 09
1
Join using :THROUGH - SQL is wrong even when using :SOURCE
Here''s a join table for an educational institution:
create_table "student_appointments", :force => true do |t|
t.column "supervisor_id", :integer, :default => 0, :null => false
t.column "student_id", :integer, :default => 0, :null => false
t.column "course_id", :integer, :default => 0, :null => false
[other columns
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
2012 Jan 03
1
Can Arel handle UPPER and LIKE condition?
Hello all, I''ve recently been on a project where somewhere needs
using case insensitive search(using UPPER(name) LIKE '''') and LIKE condition,
I want to use arel and don''t use the old style string concatenation,
can arel handle this?
But I check on arel documentation, doesn''t seems have any upper/like
operator,
and check on arel source, under
2010 Jun 20
0
ActiveRecord and ARel: correlated subqueries?
I''m trying to figure out how to use ActiveRecord in conjunction with
ARel. In particular, I''d like to replace my residual literal SQL with
ARel, if only I could see how.
Let''s take Article with multiple Versions as an example. With ARel
alone, I can find articles with their latest versions like this
articles = Article.arel_table
versions = Article.arel_table
2011 Jun 04
0
Rails 3.1 : Complex database query with Arel 2
Hi,
I''ve search for documentations on queries with Arel 2 but there is
pretty nothing and all I''ve found is for Arel 1 so I''ve run into
NoMethodError: undefined method `[]'' for
#<Arel::SelectManager:0x00000003f1b820> errors with join syntax.
My query is barely simple but involve nesting queries. I have 4 tables.
Assets, Deposits, Orders and OrderLines
2011 May 11
2
Issue with Arel::SelectManager and insert Method
Hello,
Arel::SelectManager (arel 2.0.9) uses following statement to insert a
new record:
@engine.connection.insert im.to_sql, ''AREL'', primary_key_name,
primary_key_value
But in DatabaseStatements insert ist defined as:
insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
Actually, Arel::SelectManager does not use the sequence name. This
leads to issues
2010 Nov 24
0
Surprise in (delete_all | clear | destroy_all) on association
Hi,
I was very surprised by difference of delete_all on association vs
model(delegated to relation).
Given TaskFilter.has_many(:qualifiers, :class_name=>''TaskFilterQualifier'')
TaskFilter.delete_all => one DELETE statement
Without :dependent option on "qualifiers" association
TaskFilter.first.qualifiers.delete_all =>
SELECT `task_filter_qualifiers`.* FROM
2011 Nov 22
4
A "strict Arel" mode for ActiveRecord to prevent SQL injection vulnerabilities
Hello rubyonrails-core,
I’ve been looking into possible changes to ActiveRecord / Arel to make it
easier to write Rails applications that are free of SQL injection
vulnerabilities, and in particular do so in a way that makes it easy for a
code reviewer to verify that the app is safe from such bugs.
The concern:
-----------------
With the ActiveRecord API as is, it’s relatively easy to write
2006 May 28
7
Self-referential has_many :through relationship
Hi,
I have a self-referential has_many :through relationship setup to
track relationships between users. Basically relationships are
modeled as a join table with an extra column ''relation''.
create table relationships (
user_id integer unsigned not null,
friend_id integer unsigned not null,
relation char(1) not null,
)
--- relations ---
f = friend
r = request to
2006 Jan 06
2
Re: Some advice on DB modeling
I have more or less the same problem. I''m trying to build a system where
users can enter their friends. But the solutions seems not to work for me.
I used same sql:
CREATE TABLE `friends` (
`user_id` int(11) NOT NULL default ''0'',
`friend_id` int(11) NOT NULL default ''0'',
KEY `user_id` (`user_id`),
KEY `friend_id` (`friend_id`),
2012 Mar 13
2
[Arel]Building query, but can't get a proper output
I have the following code:
advertisements_arel = Advertisement.order("advertisements.id
DESC").arel
@advertisements = (params[:website_id].present? ?
advertisements_arel.where(:website_id => params[:website_id]) :
advertisements_arel).to_a
It returns a struct Arel::SelectManager::Row data
But I''d like it to return an array of Advertisement objects (like it
would
2011 Jul 25
5
Arel quiz: complex queries with associations
I have a real-world application with some complex queries that I want to
convert to Arel (as part of an upgrade to Rails 3.1). So that I can
understand what I''m doing before I flail around in my real app, I wrote
a little sample app (just the models) with some similar associations --
one table joined with itself and more tables that join to another table,
so there are some queries that
2011 Apr 14
0
arel engine
I want to write an arel engine to run an arel-based client against a RESTful
back-end.
I''ve seen people talk about it, but haven''t seen it actually done.
Is it possible? What is the best place to find info/examples on how to do
it?
tx, Andy
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this
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,
2006 Mar 25
0
Self-Referential Many-To-Many relationships where the relationship itself has data.
Trying to model a bunch of users that have friends that are other
users. clearly a job for has_and_belongs_to_many, but the trick is,
they have ratings for their friends. I have gone through the Rails
Recipes book, and it seems like I''m trying to combine the
self-referential many-to-many recipe (12) and the many to many
relationships where the relationship itself has data recipe (16). So
2011 Feb 26
1
How to manage the form of a model that has two foreign keys
Hi,
Basically I have two models: User and Godfather. The godfather table
has three columns:
- user_id (FK --> User)
- user_godfather_id (FK --> User)
- description (text)
Inside each model class, I am adding the following associations:
class User < ActiveRecord::Base
has_many :godfathers # for user_id
has_many :godfathers, :foreign_key =>
2010 Oct 11
8
Nooby Stuck - "has_and_belongs_to_many" relationship
trying to set up a "has_and_belongs_to_many" relationship
would very much appreciate the help, not sure what im doing wrong at all.
Scheme.rb
class Scheme < ActiveRecord::Base
validates :schemename, :presence => true
belongs_to :user
has_many :levels, :dependent => :destroy
has_and_belongs_to_many :works
end
Work.rb
class Work < ActiveRecord::Base