Displaying 20 results from an estimated 45 matches for "to_sql".
Did you mean:
to_s
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
2006 Feb 22
2
Using ez_where
...@display_ad = DisplayAd.new(params[:display_ad])
cond = Caboose::EZ::Condition.new do
pub_date == ''@display_ad.pub_date''
io_number =~ ''@display_ad.io_number''
end
puts @display_ad.pub_date
puts @display_ad.io_number
puts cond.to_sql
#display_ad = DisplayAd.find(:all, conditions => cond.to_sql )
#render :action => ''list''
end
127.0.0.1 - - [21/Feb/2006:22:31:46 PST] "GET /favicon.ico HTTP/1.1"
200 0
- -> /favicon.ico
2004-06-02
12345
pub_date = ? AND io_number LIKE ?
@display_...
2006 Feb 02
2
uninitialized constant
...r::Sorter.new self, %w(icao host_id name),
@params[''sort''], @params[''order''], ''icao'', ''ASC''
@pages = Paginator.new self, Airport.count, 10, @params[''page'']
@airports = Airport.find_all nil, @sorter.to_sql,
@pages.current.to_sql
render_action ''none'' if 0 == @airports.length
end
Can anyone help? If you need more information I will give it if I can.
BTW, I''m a RoR newbie so if this is something really simple, I''m sorry.
--
Posted via http://www.ruby-forum.com...
2006 Jan 30
2
:condition not being applied
...l_id=#{portal_id}").length, 25, @params[''page''];
@resources = Resource.find_tagged_with( :any => tag, :condition => "tags_resources.portal_id=#{portal_id}", :separator=> '' '',
:limit => "#{@resource_pages.current.to_sql[1]}, #{@resource_pages.current.to_sql[0]}");
I have two Active Record classes, Resource and Tag.
Can anyone please tell what am I missing here?
Many thanks in advance.
Frank
---------------------------------
What are the most popular cars? Find out at Yahoo! Autos...
2008 Sep 17
13
Capturing the sql from a statement without executing it?
Hi guys,
Is there an elegant way to capture the sql that would have been
executed by an ActiveRecord statement, without actually executing
it? :)
I''m imagining something like
sql = User.find(1).groups.to_sql
or perhaps
sql = ActiveRecord::Base.capture_sql { User.find(1).groups }
resulting in sql = ''SELECT * FROM groups INNER JOIN memberships....
WHERE users.id = 1''.
Any ideas?
Thanks,
Stephen
--~--~---------~--~----~------------~-------~--~----~
You received this message becau...
2006 Feb 19
8
building multiple find conditions
I am trying to allow for AND type ''find'' but to allow for simply a
single set of find criteria.
controller code...
@vw_string = @vw_string1 = @vw_string2 = @vw_string3 = []
if params[:beg_intake_date] != "" then
@vw_string1 = ["intake_date between ? and ?",
params[:beg_intake_date], params[:end_intake_date] ]
end
if
2011 Sep 13
4
Changing adapters in ActiveRecord does not change the generated sql
...r to be tested always fails with
invalid sql.
Here''s an example:
ActiveRecord::Base.establish_connection :adapter => ''mysql2'', :database =>
''my_test_db'', :username => ''root'', :password => ''''
User.scoped.to_sql #=> "SELECT `users`.* FROM `users`"
ActiveRecord::Base.establish_connection :adapter => ''postgresql'', :database
=> ''my_test_db'', :username => ''root'', :password => ''''
User.scoped.to_sql #=> &qu...
2006 Apr 16
3
variable variables?
Hi everyone,
Does Ruby support variable variables like PHP
(http://www.php.net/manual/en/language.variables.variable.php)? Or do I have
to use eval, like
some_hash.each_pair{|key, pair|
eval "#{key} = #{value}"
}
Or is there some other way?
I''m actually trying to figure this out in order to use ez_where to create
its conditions from a hash, so if this isn''t even
2013 Apr 19
0
Question marks in SQL string literals
...covered that AR tries to treat question marks inside SQL
string literals as parameters, however this behaviour shows in very rare
cases, for example (very odd, but...):
User.where("NOT EXISTS (#{ Comment.where(''user_id = users.id AND body ILIKE
?'', ''%?'').to_sql }) AND created_at > ?", Date.yesterday).to_sql
It will fail, because inner SQL will contain qmark inside of literal, which
AR will count as query parameter
(https://github.com/rails/rails/blob/master/activerecord/lib/active_record/sanitization.rb#L129),
but there is only one argument....
2006 Apr 15
2
ez_where : i''m puzzled
...ase}%"
logger.info "condition is #{condition_clause}"
unless @phrase.nil?
condition = Caboose::EZ::Condition.new :affiliates do
affiliate_name =~ "%#{@phrase}%" # <<< here''s the problem
end
options[:conditions] = condition.to_sql
logger.info "ajax param is #{@phrase}"
logger.info "ez condition is #{condition.to_sql}"
end
The output from the logs is:
ajax param is map
ez condition is
In other words, the the where clause is not being constructed. However, if I
change the line marked abov...
2006 Feb 15
10
STI Question
Hi everyone,
I have 3 types of people (for now):
Staff
Faculty
Students
To break them up into classes, but keep them in the same People table,
I''ve broken them up like so (code and ''ends'' snipped):
class Person < ActiveRecord::Base
class Employee < Person
class Staff < Employee
class Faculty < Employee
class Student < Employee
So, when I insert
2010 Jul 08
25
Prepared SQL statements
Dear all great developers.
I wonder if there is any work being done or thoughts being shared
regarding prepared SQL statements.
Currently I am in heavy need of tuning SQL INSERTS that insert large
(3MB) images into blobs.
I am using rails 2.3.5 with postgres adapter and pg driver.
Any information would be appreciated.
Jarl
--
You received this message because you are subscribed to the
2005 Aug 04
1
Pagination and :include (eager associations)
...ges, @links = paginate :link, :per_page => 10, :order_by
=> sort_clause
and here the work around, using the "classic" method
# @link_pages = Paginator.new self, Link.count, 10, @params[''page'']
# @links = Link.find_all nil, sort_clause, @link_pages.current.to_sql
# limit = @link_pages.current.to_sql.first
# offset = @link_pages.current.to_sql.last
# @links = Link.find( :all, :order => sort_clause, :limit =>
limit, :offset => offset,
# :include => [:linktype_remote] )
Is there a reason for not allowing :include...
2011 Apr 10
0
Arel Union does not support #order or #limit
...m via `union`:
>
> rel_a = ActiveRecord::Relation.new(MyModel).where(:id => 3)
> rel_b = ActiveRecord::Relation.new(MyModel).where(:id => 5)
> new_rel = rel_a.union(rel_b)
> new_rel.to_s #=> "#<Arel::Nodes::Union:0x3da6260>"
> new_rel.to_sql #=> "( SELECT `my_models`.* FROM `my_models`
> WHERE (`my_models`.`id` = 3) UNION SELECT `my_models`.* FROM
> `my_models` WHERE (`top_items`.`id` = 5) )"
>
> Ideally, we''d be able to sort and limit the resulting `UNION`
> results in the SQL. According to [...
2006 Apr 18
3
ez_where query question
I''m having fun composing queries with ez_where, but am stuck on how to
formulate the following using the ez syntax:
(begin_date >= ? OR end_date >= ?) AND (description LIKE ? OR name LIKE ?)
There are two clauses, each containing OR operators (the ez ''any'' syntax)
but both clauses must evaulate to true for a match.
Can anyone suggest the proper way to construct
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 for instance with
activerecor...
2006 Apr 16
11
Best way to sort categories w/ pager
Ahoy,
I made this pager,
" def list
@item_pages = Paginator.new self, Item.count, 10, @params[''page'']
@items = Item.find :all, :conditions => "category_id =
#{params[:condition]}",
:limit => @item_pages.items_per_page,
:offset => @item_pages.current.offset
@categories = Category.find_all
2006 May 23
3
ez-where headscratch
Hi there,
I''m puzzled by this apparently simple query I can''t manage to reassemble
using ez_where plugin.
cond = Caboose::EZ::Condition.new :my_table do
start_on < Time.now
any {end_on > Time.now; end_on.nil?}
end
I keep getting the following result :
>> cond.to_sql
=> ["my_table.start_on < ? AND (my_table.end_on > ?)", Tue May 23
17:11:43 CEST 2006, Tue May 23 17:11:43 CEST 2006]
while the expected result would be :
["my_table.start_on < ? AND (my_table.end_on > ? OR my_table.end_on IS
NULL)", Tue May 23 17:11:43 CEST 20...
2006 Mar 22
4
How to write this SQL query?
Hi!
Is there rails version of "where column in (value1, value2, ...)"?
I know i could do OR many times, but this way is shorter.
I''m ruby/rails newbie, so i have a problem with converting the hash,
which i''m receving from the search form into the string for :conditions
in find method.
Could i instead of creating one, complicated (for me) query do something
like
2010 Apr 12
2
[PATCH] Access to more Arel predicate types from where condition hash
...quot; LIKE
''Hello%'')
Among other things, this change would prevent it from being necessary
to resort to SQL strings in order to achieve something as simple as a
a "published_at is not null" where clause.
Article.where(''published_at#noteq'' => nil).to_sql
SELECT "articles".* FROM "articles" WHERE ("articles"."published_at"
IS NOT NULL)
It plays nicely with scopes:
scope :published, where(''published_at#noteq'' => nil)
In general, I don''t see a whole lot of downsides to this.....