search for: databasestatements

Displaying 12 results from an estimated 12 matches for "databasestatements".

Did you mean: database_statements
2007 Jan 18
4
Defining the expected behavior of DatabaseStatements.execute()
It would be very helpful if the core team could define and document the expected behavior of DatabaseStatements.execute(). The implementations appear to vary. Most adapters will return some sort of native result set, SQL Server returns nil and expects a block, DB2 and Sybase return the affected row count. So please, will someone in core explain the expected behavior and can the execute() documentation in th...
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 activerecord-jdbc-adapter and Oracle, when you use sequence names ignoring rails conventions. Is it p...
2006 Jan 11
2
How to execute an SQL statement in rails?
Hello, This is probably a silly question but looking at "api.rubyonrails.org", I can''t seem to figure out which method I should be using ... I want to execute an sql statement, like "truncate table BLAH" from within one of my rails app ... What''s the "right" way to do this? Thanks, /B -- Bruno Mattarollo <bruno.mattarollo@gmail.com>
2006 Jun 15
4
testing with transactions
Hello! I experienced problems with testing transactions which are supposed to be rolled back, but are not, because of transactional fixtures eliminating the inner transaction. Can this be worked around somehow without turning off transactional fixtures? Maybe savepoints can help this? Does anyone have any experience with savepoints to achieve nested transaction functionality? Both Postgres
2006 Mar 02
2
custom sql queries beyond CRUD
Hi, I am just starting of in rails. I am trying to understand the features of rails and I have this burning question. (and search is not available now): Apart from relying on the automatic CRUD sql script produced, is there a way I can create my own sql script ex: with many joins between exixting tables (for reporting ). All I need is to declare the custom query and place the result in a
2006 Mar 05
0
Can I execute DML from within Rails?
...te a DML statement against a MySQL database from within Rails? I have a table I''m using for batch processing. It needs to be truncated to reset the primary key before each batch insert statement. I looked at the API here: http://api.rubyonrails.com/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#M000532 and didn''t notice anything that looked like it would work. Thanks in advance. -- Best Regards, -Larry "Work, work, work...there is no satisfactory alternative." --- E.Taft Benson -------------- next part -------------- An HTML attachment was scrubbed.....
2006 Nov 13
1
Removing column default with a migration
Hi guys, I''m having problems removing the default from a boolean field. I''m using the following statement: change_column :valuations, :too_many_adults, :integer, :null => true but it''s adding DEFAULT ''0'' to the SQL statement. I''m having no luck using change_column_default either. Is this possible? Gareth
2006 Jun 15
3
Can I call MySql statements directly??
Hi All. I have a mysql statement that I would really really like to call from my Ruby program which goes like this: SELECT a, b, DAYOFWEEK(date_time) as DOW, HOUR(date_time) at hr, AVG(x/y) FROM records; This is possible by creating a 3-dimentional array of a, b, date_time containing x/y, and then finding averages and putting it into a 4-dimensional array of a, b, dow,
2006 Jul 05
10
Scalable alternative to #find_all
Is there any scalable alternative to iterating all the records of a certain model? #find_all seems to load everything into memory. With 500.000 records it will be a swap storm. Pedro.
2006 Mar 06
6
Executing SQL in rails, and the types of the data returned
Hi, Every once in while I have to run SQL by hand, in my models mostly. But I''m wondering if there is a better way of doing it than I do. And, I have a question concerning types of the fields in the result the query produces. First, about the types. In a certain model, to get and return the value of a boolean function, I have to do: result =
2008 May 30
9
find_by_sql without a model? how to do this?
Hi, I''d like to do a "find_by_sql" without a model (e.g. <model name>.find_by_sql("...")) as the results I get back are a once off special, and I''m happy to handle them as an array. How do I do this? "ActiveRecord::Base.find_by_sql(...)" does not seem to work? Background - At the moment I''m doing within a model <model_name>,
2011 Nov 22
4
A "strict Arel" mode for ActiveRecord to prevent SQL injection vulnerabilities
...ly include the value of a request parameter, e.g via string interpolation). For an initial experiment, see below. For #2, a possible approach might be to encapsulate strings obtained from flattening Arel in a specific type, e.g. “ArelSqlStatement”; probably in ActiveRecord::ConnectionAdapters::DatabaseStatements.to_sql . Then (if strict arel mode is enabled), in ActiveRecord::ConnectionAdapters::XyzAdapter.select, enforce that sql === ArelSqlStatement. Question: ------------ * Is this a terrible idea, or is there some reason this wouldn’t work in practice? Note that it would of course be optional, a...