similar to: ActiveRecord and ARel: correlated subqueries?

Displaying 20 results from an estimated 1000 matches similar to: "ActiveRecord and ARel: correlated subqueries?"

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))
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
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
2011 Nov 03
0
Arel table aliases and ActiveRecord::Relation help: how to specify "multiple has_many items in a query"
What is the recommended way to use table aliases with ActiveRecord::Relation these days? In prior versions of Rails, this would work: assume (pseudo code): model A has_many b''s model B ,,, at = B.arel_table atalias = at.alias(at.name + "_1") A.join(:b).join(atalias).where(atalias[:a_id].eq(at[:a_id]).where("b.widget =
2012 Sep 19
0
How to copy model with arel_table instance
Hi all I want to make copy of current scoped object, then change some stuff in arel_table(i need to change table_alias, because i have complicated query) and arel(SelectManager) def self.do_smth query = scoped.dup puts query.arel_table.object_id == scoped.arel_table.object_id # true end Theoretically i can dup arel(SelectManager) but i can not find how to add table alias to that instance
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`:
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
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
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
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
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
2010 Nov 15
1
Arel 2 isn't playing nice with my legacy tables
Specifically, it''s not playing nice with any type that it doesn''t recognize, eg. SET, ENUM, etc.. Just trying to start my Rails 3.0.2 app I get a NotImplementedError exception "Column type `` is not currently handled" on the first SET field it encounters. Am I missing something here? Should I be disabling Arel for legacy tables or something? Thanks, Jason -- You
2011 Feb 22
0
Arel: misunderstanding with intersections
Hi, I''ve been playing with Arel for a few days, but I feel really confused about predicates / arrays intersection. Let''s say I have 3 models: users, (bank) accounts and transfers. An account belongs to a user, and a transfer is made of a source and target accounts (see the snippets below). Given a user, I want to query his transfers. I can go this way in the User class: def
2011 May 05
9
[threadsafe] Arel ToSql visitor is not threadsafe
Hey, We hit a bug today because Arel::Visitors::ToSql is not threadsafe. Here is what is happening: Arel::Visitors::ENGINE_VISITORS is a cache of visitors instances. These instances are not inherently threadsafe because it contains state ''@last_column'', ''@connection'' that is shared between threads. The other variables ''@pool'',
2011 Apr 18
12
Arel - clone bug (and fix), feature requests
Hi all, I''ve been playing around with Arel this week (actually outside of Rails) and found an issue with the clone implementation. I''ve added a patch and a testcase here: https://github.com/codders/arel/commit/660f706491ac012cb133554cffeaa6b9ae6046e9 and made a pull request against the rails/arel repo. I''ve also been playing around with support for ordering on
2005 Oct 09
1
Setting the user for FastCGI processes?
I''d like to run the FastCGI as a different user than the Apache2 server (www-data on Debian). I take it this is possible in some way with suExec2, but so far I haven''t figured out how to do it. Michael -- Michael Schuerig Life is just as deadly mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org As it looks
2005 Aug 16
1
Defining model classes for enumerations
I have several tables for enumerations. They all have the same content: id, name, position. I''d like to avoid the tedious work of defining a class for each one explicitly. Not least, in order to avoid clutter in the model directory. Here''s what I''ve come up with: class EnumRecord < ActiveRecord::Base def self.define_enums(*enums) enums.each do |spec|
2005 Sep 06
4
url_for: :overwrite_params went missing
Somewhere between 0.13.1 and the current SVN version the :overwrite_params option to url_for (and related methods) went missing. I can''t tell whether this was deliberate or by mistake, and I have no idea how to get the same functionality in some other way either. Michael -- Michael Schuerig Life is what happens
2008 Jan 21
1
JavaScript book recommendations
No, not a question, but a few suggestions. I take it that everyone serious about using Prototype & Co. already has Christophe''s (Porteneuve) Prototype and Script.aculo.us book. Apart from that, I''d like to point out two new, library-agnostic books: Cameron Adams and several others The Art & Science of JavaScript Sitepoint 2008 http://www.sitepoint.com/books/jsdesign1/