aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
Commit message (Collapse)AuthorAgeFilesLines
* Replace trivial regexp with string or index, twice as fastKelley Reynolds2014-03-281-1/+1
|
* No need to binds be optionalRafael Mendonça França2014-03-131-2/+2
|
* Make select_all on query cache accept a Relation without binds.Arthur Neves2014-03-131-12/+9
| | | | | [fixes #14361] [related #13886]
* Fix regression on `.select_*` methods.Arthur Neves2014-01-301-3/+14
| | | | | | | | | | | | | | | | | | This was a common pattern: ``` query = author.posts.select(:title) connection.select_one(query) ``` However `.select` returns a ActiveRecord::AssociationRelation, which has the bind information, so we can use that to get the right sql query. Also fix select_rows on postgress and sqlite3 that were not using the binds [fixes #7538] [fixes #12017] [related #13731] [related #12056]
* Revert "ask the fixture set for the sql statements"Aaron Patterson2014-01-091-5/+1
| | | | | | | | | This reverts commit 026d0555685087845b74dd87a0417b5a164b1c13. Conflicts: activerecord/lib/active_record/fixtures.rb Fixes #13383
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-12-201-1/+1
|\
| * Typos. return -> returns. [ci skip]Lauro Caetano2013-12-031-1/+1
| |
* | Remove `DatabaseStatements#case_sensitive_equality_operator`. It has been ↵Ryuta Kamizono2013-11-291-4/+0
|/ | | | deprecated already.
* ask the fixture set for the sql statementsAaron Patterson2013-11-041-1/+5
|
* Check if the SQL is not a prepared statementRafael Mendonça França2013-09-111-1/+1
| | | | | | | | | When the adapter is with prepared statement disabled and the binds array is not empty the connection adapter will try to set the binds values and will fail. Now we are checking if the adapter has the prepared statement disabled. Fixes #12023
* Revert "Do not dup the binds when visiting the AST"Rafael Mendonça França + Kassio Borges2013-08-311-1/+2
| | | | | | This reverts commit 71ff7d9c6592b93e2c810a1f464943dd7bd02c7f. Reason: I need to check with @jeremy if we can do this.
* Do not dup the binds when visiting the ASTRafael Mendonça França2013-08-311-2/+1
| | | | | | | The visitor have to consume the bind parameters to make the statements work when the prepared statement option is disabled. Fixes #12023
* drop extra variableVipul A M2013-08-121-2/+2
|
* Fix indentation.kennyj2013-07-241-8/+8
|
* Simplify select_one method.kennyj2013-07-241-2/+1
| | | | | | The select_all method always returns ActiveRecord::Result instance, and the ActiveRecord::Result includes Enumerable mixin. If #empty?, #first method returns nil. Thus we can simplify this method.
* Defines the return type of select / select_all method.kennyj2013-07-231-4/+2
|
* SQLite3 3.6.8+ supports savepointsNeeraj Singh2013-03-071-1/+2
| | | | | http://www.sqlite.org/lang_savepoint.html https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L130-L132
* schema cache already has the columns as a hash, so use thatAaron Patterson2012-11-251-1/+1
|
* speed up fixture loading by querying the schema cache for column namesAaron Patterson2012-11-251-1/+1
|
* Migration of docs to 1.9 hash syntaxAvnerCohen2012-10-231-1/+1
|
* Support for partial inserts.Jon Leighton2012-09-281-1/+1
| | | | | | | | | | | When inserting new records, only the fields which have been changed from the defaults will actually be included in the INSERT statement. The other fields will be populated by the database. This is more efficient, and also means that it will be safe to remove database columns without getting subsequent errors in running app processes (so long as the code in those processes doesn't contain any references to the removed column).
* Support for specifying transaction isolation levelJon Leighton2012-09-211-6/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If your database supports setting the isolation level for a transaction, you can set it like so: Post.transaction(isolation: :serializable) do # ... end Valid isolation levels are: * `:read_uncommitted` * `:read_committed` * `:repeatable_read` * `:serializable` You should consult the documentation for your database to understand the semantics of these different levels: * http://www.postgresql.org/docs/9.1/static/transaction-iso.html * https://dev.mysql.com/doc/refman/5.0/en/set-transaction.html An `ActiveRecord::TransactionIsolationError` will be raised if: * The adapter does not support setting the isolation level * You are joining an existing open transaction * You are creating a nested (savepoint) transaction The mysql, mysql2 and postgresql adapters support setting the transaction isolation level. However, support is disabled for mysql versions below 5, because they are affected by a bug (http://bugs.mysql.com/bug.php?id=39170) which means the isolation level gets persisted outside the transaction.
* simplify rescueJon Leighton2012-09-151-3/+3
|
* Remove our use of #outside_transaction?Jon Leighton2012-09-151-32/+8
| | | | | | | | | | | | | | | | This method was first seen in 045713ee240fff815edb5962b25d668512649478, and subsequently reimplemented in fb2325e35855d62abd2c76ce03feaa3ca7992e4f. According to @jeremy, this is okay to remove. He thinks it was added because at the time we didn't have much transaction state to keep track of, and he viewed it as a hack for us to track it internally, thinking it was better to ask the connection for the transaction state. Over the years we have added more and more state to track, a lot of which is impossible to ask the connection for. So it seems that this is just a relic of the passed and we will just track the state internally only.
* Remove the transaction_open variableJon Leighton2012-09-151-21/+28
|
* Move transaction joinability into the transaction objectJon Leighton2012-09-151-13/+13
|
* Alter the naming structure a bitJon Leighton2012-09-151-2/+2
|
* DRYJon Leighton2012-09-151-4/+8
|
* Don't do the rollback in #commitJon Leighton2012-09-151-1/+1
| | | | | The caller needs to have knowledge of the rollback either way, so do it all in the caller (#transaction)
* Store the transaction number in the transaction objectJon Leighton2012-09-151-1/+0
| | | | This avoids us having to manually increment and decrement it.
* Start to tease out transaction handling into a state machineJon Leighton2012-09-151-79/+28
|
* Revert "create a transaction object and point AR objects at that object ↵Jon Leighton2012-09-151-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | during a" This reverts commit c24c885209ac2334dc6f798c394a821ee270bec6. Here's the explanation I just sent to @tenderlove: Hey, I've been thinking about about the transaction memory leak thing that we were discussing. Example code: post = nil Post.transaction do N.times { post = Post.create } end Post.transaction is going to create a real transaction and there will also be a (savepoint) transaction inside each Post.create. In an idea world, we'd like all but the last Post instance to be GC'd, and for the last Post instance to receive its after_commit callback when Post.transaction returns. I can't see how this can work using your solution where the Post itself holds a reference to the transaction it is in; when Post.transaction returns, control does not switch to any of Post's instance methods, so it can't trigger the callbacks itself. What we really want is for the transaction itself to hold weak references to the objects within the transaction. So those objects can be GC'd, but if they are not GC'd then the transaction can iterate them and execute their callbacks. I've looked into WeakRef implementations that are available. On 1.9.3, the stdlib weakref library is broken and we shouldn't use it. There is a better implementation here: https://github.com/bdurand/ref/blob/master/lib/ref/weak_reference/pure_ruby.rb We could use that, either by pulling in the gem or just copying the code in, but it still suffers from the limitation that it uses ObjectSpace finalizers. In my testing, this finalizers make GC quite expensive: https://gist.github.com/3722432 Ruby 2.0 will have a native WeakRef implementation (via ObjectSpace::WeakMap), hence won't be reliant on finalizers: http://bugs.ruby-lang.org/issues/4168 So the ultimate solution will be for everyone to use Ruby 2.0, and for us to just use ObjectSpace::WeakMap. In the meantime, we have basically 3 options: The first is to leave it as it is. The second is to use a finalizer-based weakref implementation and take the GC perf hit. The final option is to store object ids rather than the actual objects. Then use ObjectSpace._id2ref to deference the objects at the end of the transaction, if they exist. This won't stop memory use growing within the transaction, but it'll grow more slowly. I benchmarked the performance of _id2ref this if the object does or does not exist: https://gist.github.com/3722550 If it does exist it seems decent, but it's hugely more expensive if it doesn't, probably because we have to do the rescue nil. Probably most of the time the objects will exist. However the point of doing this optimisation is to allow people to create a large number of objects inside a transaction and have them be GC'd. So for that use case, we'd be replacing one problem with another. I'm not sure which of the two problems is worse. My feeling is that we should just leave this for now and come back to it when Ruby 2.0 is out. I'm going to revert your commit because I can't see how it solves this. Hope you don't mind... if I've misunderstood then let me know! Jon
* create a transaction object and point AR objects at that object during aAaron Patterson2012-09-071-3/+5
| | | | transaction.
* use Hash#fetch to eliminate conditionalAaron Patterson2012-08-241-8/+3
|
* This method is useless without a block, so remove testAaron Patterson2012-08-201-11/+9
|
* remove unused variableAaron Patterson2012-08-201-1/+1
|
* initialize instance variables to avoid conditionalsAaron Patterson2012-08-201-2/+7
|
* Avoid unnecessary catching of Exception instead of StandardError.Dylan Smith2012-06-171-2/+2
|
* Work around undiagnosed bug that's draining a relation's bind_valuesJeremy Kemper2012-05-311-0/+1
|
* Merge pull request #5698 from dougcole/support_postgresql_partitioningAaron Patterson2012-04-271-2/+2
|\ | | | | Support postgresql partitioning by making INSERT RETURNING optional
| * add use_returning as a postgresql connection configDoug Cole2012-03-311-2/+2
| |
* | Fix delete_all when chained with joins.Rafael Mendonça França2012-04-101-3/+17
| | | | | | | | Closes #5202 and #919
* | Remove unnecessary articles.Waseem Ahmad2012-04-031-3/+3
|/
* use bind values for join columnsAaron Patterson2012-02-271-4/+4
|
* prepared statements can be disabledAaron Patterson2012-02-211-7/+9
|
* fix nodocsVijay Dev2011-12-091-3/+3
|
* Use new SelectManager#projections= methodJon Leighton2011-08-151-2/+2
|
* use update.key instead of update.ast.key. make better use of select manager.Jon Leighton2011-08-151-2/+2
|
* Refactor building the update managerJon Leighton2011-08-151-5/+3
|
* Support for multi-table updates with limits, offsets and ordersJon Leighton2011-08-151-0/+3
|