Displaying 20 results from an estimated 300 matches similar to: "Capturing the sql from a statement without executing it?"
2007 Aug 05
1
Activerecord Query Generation
Is there a way to just retrieve the sql that would be generated by an
activerecord call without actually executing the call?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
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
Hi All,
I am trying to pass values to ez_where to construct my conditions. I
need
to know how the params need to be formated for ez_where.
My search class looks like this:
def search
@display_ad = DisplayAd.new(params[:display_ad])
cond = Caboose::EZ::Condition.new do
pub_date == ''@display_ad.pub_date''
io_number =~
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
2006 Feb 02
2
uninitialized constant
Ok, I searched but couldn''t find anything and I even tried the RoR IRC
channel with no help.
I get this error:
uninitialized constant Airport
I used this code which I got from the RoR site.
helper :sorting
def list
@sorter = SortingHelper::Sorter.new self, %w(icao host_id name),
@params[''sort''], @params[''order''], ''icao'',
2006 Jan 30
2
:condition not being applied
I am using acts_as_taggable and everything seems to be working except that
:condition => "tags_resources.portal_id=#{portal_id}"
is not being applied.
@resource_pages = Paginator.new self, Resource.find_tagged_with(:any => tag, :condition => "tags_resources.portal_id=#{portal_id}").length, 25, @params[''page''];
@resources
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
2006 Jun 20
2
Problem with "can''t dump anonymous class Class"
I submitted this earlier, but the web forums went down and I''ve screwed up
the thread, so I''m starting over.
I''m trying to built a document upload system. The system has a main
Document model with different subclasses for different types of documents.
With the code below, if I attempt to create a Document, it works fine, but
if I attempt to use one of the subclasses, I
2011 Sep 13
4
Changing adapters in ActiveRecord does not change the generated sql
If I establish a new connection with a new adapter (ie. switch from mysql to
postgresl) the generated sql is still mysql specific. I tried all sorts of
reset methods on AR::Base but to no avail. There must be something being
memoized on ActiveRecord base that has to do with the adapter and it doesn''t
get cleared when you establish a connection with a new adapter.
I know this
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
2006 Apr 15
2
ez_where : i''m puzzled
I have the following code:
condition_clause = "%#{@phrase}%"
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
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
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 Jun 19
3
can''t dump anonymous class Class
I''m trying to create a document upload system, where most of the code is
the super class Document and just the path to file on the system is
controlled by the sub classes. When I attempt to use my code, I get the
following when I try to save the document.
can''t dump anonymous class Class
Any ideas?
** Migration **
class CreateDocuments < ActiveRecord::Migration
def
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
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
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
2007 Jul 23
2
Firebird, fireruby
Hi Guys
I am pretty new to Ruby. One of our client is using Firebird as his
backend database. I have to create a script which will connect to his
database, fetch some data and update few tables in MS-SQL database.
Now problem is: i have installed FireRuby, got databaes, changed my
database.yml file.
I am trying to display all the users in Members table. but i am
getting following error:
2006 Jan 10
1
sql server freetds/odbc question
I''m having an error from Linux via freeTDS/ODBC to SQL Server with
cod that runs fine against SQLite and MySQL. Here''s the code:
def find_recipes_for_workorder_by_id
@recipe_pages, @recipes = paginate_with_sort :recipes, :per_page
=> 10, \
:conditions => ["recipe.workorder_id = ?", params
[:workorder]]
render :template =>