aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
...
| * Improve AR connection fork safetyMatthew Draper2017-11-181-0/+13
| | | | | | | | | | | | Use whatever adapter-provided means we have available to ensure forked children don't send quit/shutdown/goodbye messages to the server on connections that belonged to their parent.
* | Merge pull request #31035 from BrentWheeldon/bmw-db-load-deadlockMatthew Draper2017-11-181-1/+2
|\ \ | |/ |/| Prevent deadlocks with load interlock and DB lock.
| * Prevent deadlocks with load interlock and DB lock.Brent Wheeldon2017-11-091-1/+2
| | | | | | | | | | | | | | | | | | | | This fixes an issue where competing threads deadlock each other. - Thread A holds the load interlock but is blocked on getting the DB lock - Thread B holds the DB lock but is blocked on getting the load interlock (for example when there is a `Model.transaction` block that needs to autoload) This solution allows for dependency loading in other threads while a thread is waiting to acquire the DB lock. Fixes #31019
* | Add missing autoload `Type` (#31123)Ryuta Kamizono2017-11-111-1/+0
|/ | | | | | | | | | | | | | | | | | | | | | | Attribute modules (`Attribute`, `Attributes`, `AttributeSet`) uses `Type`, but referencing `Type` before the modules still fail. ``` % ./bin/test -w test/cases/attribute_test.rb -n test_with_value_from_user_validates_the_value Run options: -n test_with_value_from_user_validates_the_value --seed 31876 E Error: ActiveModel::AttributeTest#test_with_value_from_user_validates_the_value: NameError: uninitialized constant ActiveModel::AttributeTest::Type /Users/kamipo/src/github.com/rails/rails/activemodel/test/cases/attribute_test.rb:233:in `block in <class:AttributeTest>' bin/test test/cases/attribute_test.rb:232 Finished in 0.002985s, 335.0479 runs/s, 335.0479 assertions/s. 1 runs, 1 assertions, 0 failures, 1 errors, 0 skips ``` Probably we need more autoloading at least `Type`.
* Remove deprecated arguments from `#verify!`Rafael Mendonça França2017-10-231-4/+1
|
* Remove deprecated method `supports_primary_key?`Rafael Mendonça França2017-10-231-5/+0
|
* Remove deprecated method `supports_migrations?`Rafael Mendonça França2017-10-231-5/+0
|
* [Active Record] require => require_relativeAkira Matsuda2017-10-211-6/+6
| | | | This basically reverts 9d4f79d3d394edb74fa2192e5d9ad7b09ce50c6d
* Add JSON attribute test cases for SQLite3 adapterRyuta Kamizono2017-10-051-0/+2
|
* Don't use `quoted_table_name` in `limited_ids_for`Ryuta Kamizono2017-09-141-1/+5
| | | | | | Because `quoted_table_name` doesn't respect table alias. We should use `arel_attribute` for that, so I added `column_name_from_arel_node` to generate column name from an arel node.
* Refactor `SchemaDumper` to make it possible to adapter specific customizationRyuta Kamizono2017-08-221-1/+0
| | | | | | | Currently `SchemaDumper` is only customizable for column options. But 3rd party connection adapters (oracle-enhanced etc) need to customizable for table or index dumping also. To make it possible, I introduced adapter specific `SchemaDumper` classes for that.
* Use `predicate_builder.build_bind_attribute` wherever possibleRyuta Kamizono2017-07-281-3/+3
| | | | For less duplicated code.
* Refactor Active Record to let Arel manage bind paramsSean Griffin2017-07-241-36/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A common source of bugs and code bloat within Active Record has been the need for us to maintain the list of bind values separately from the AST they're associated with. This makes any sort of AST manipulation incredibly difficult, as any time we want to potentially insert or remove an AST node, we need to traverse the entire tree to find where the associated bind parameters are. With this change, the bind parameters now live on the AST directly. Active Record does not need to know or care about them until the final AST traversal for SQL construction. Rather than returning just the SQL, the Arel collector will now return both the SQL and the bind parameters. At this point the connection adapter will have all the values that it had before. A bit of this code is janky and something I'd like to refactor later. In particular, I don't like how we're handling associations in the predicate builder, the special casing of `StatementCache::Substitute` in `QueryAttribute`, or generally how we're handling bind value replacement in the statement cache when prepared statements are disabled. This also mostly reverts #26378, as it moved all the code into a location that I wanted to delete. /cc @metaskills @yahonda, this change will affect the adapters Fixes #29766. Fixes #29804. Fixes #26541. Close #28539. Close #24769. Close #26468. Close #26202. There are probably other issues/PRs that can be closed because of this commit, but that's all I could find on the first few pages.
* Merge pull request #29869 from kamipo/make_type_map_to_privateRafael França2017-07-211-8/+7
|\ | | | | Make `type_map` to private because it is only used in the connection adapter
| * Make `type_map` to private because it is only used in the connection adapterRyuta Kamizono2017-07-201-8/+7
| | | | | | | | | | | | | | `type_map` is an internal API and it is only used in the connection adapter. And also, some type map initializer methods requires passed `type_map`, but those instances already has `type_map` in itself. So we don't need explicit passing `type_map` to the initializers.
* | Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|/
* Don't translate non-database exceptions.Dennis Taylor2017-07-051-2/+4
| | | | The AbstractAdapter will translate all StandardErrors generated during the course of a query into ActiveRecord::StatementInvalids. Unfortunately, it'll also mangle non-database-related errors generated in ActiveSupport::Notification callbacks after the query has successfully completed. This should prevent it from translating errors from ActiveSupport::Notifications.
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-1/+1
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| | |
| * | Make ActiveRecord frozen string literal friendly.Pat Allan2017-06-201-1/+1
| |/
* / [Active Record] require => require_relativeAkira Matsuda2017-07-011-6/+6
|/
* Add comprehensive locking around DB transactionsMatthew Draper2017-04-111-1/+1
| | | | | | | | | | | | | | | | | | Transactional-fixture using tests with racing threads and inter-thread synchronisation inside transaction blocks will now deadlock... but without this, they would just crash. In 5.0, the threads didn't share a connection at all, so it would've worked... but with the main thread inside the fixture transaction, they wouldn't've been able to see each other. So: as far as I can tell, the set of operations this "breaks" never had a compelling use case. Meanwhile, it provides an increased level of coherency to the operational feel of transactional fixtures. If this does cause anyone problems, they're probably best off disabling transactional fixtures on the affected tests, and managing transactions themselves.
* Make internal methods to privateRyuta Kamizono2017-03-271-27/+13
|
* [PostgreSQL]: Replace deprecated PG constants.Lars Kanis2017-03-221-1/+1
| | | | | The old top level classes PGconn, PGresult and PGError were deprecated since pg-0.13.0: https://github.com/ged/ruby-pg/blob/master/History.rdoc#v0130-2012-02-09-michael-granger-gedfaeriemudorg
* Remove duplicated `columns` definitionRyuta Kamizono2017-03-201-8/+0
|
* Deprecate `supports_migrations?` on connection adaptersRyuta Kamizono2017-02-271-3/+3
| | | | | | | `supports_migrations?` was added at 4160b518 to determine if schema statements (`create_table`, `drop_table`, etc) are implemented in the adapter. But all tested databases has been supported migrations since a4fc93c3 at least.
* Merge pull request #28176 from kamipo/push_valid_type_up_to_abstract_adapterAndrew White2017-02-261-2/+2
|\ | | | | Push `valid_type?` up to abstract adapter
| * Push `valid_type?` up to abstract adapterRyuta Kamizono2017-02-261-2/+2
| | | | | | | | | | | | | | `valid_type?` should return true if a type exists in `native_database_types` at least. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/schema_dumper.rb#L136
* | Fix typo 'affect' -> 'effect' [ci skip]Rebecca Skinner2017-02-261-1/+1
|/
* Merge pull request #28167 from kirs/deprecate-verify-argsMatthew Draper2017-02-261-0/+3
|\ | | | | Deprecate AbstractAdapter#verify! with arguments
| * Deprecate AbstractAdapter#verify! with argumentsKir Shatrov2017-02-251-0/+3
| |
* | Ensure test threads share a DB connectioneileencodes2017-02-201-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This ensures multiple threads inside a transactional test to see consistent database state. When a system test starts Puma spins up one thread and Capybara spins up another thread. Because of this when tests are run the database cannot see what was inserted into the database on teardown. This is because there are two threads using two different connections. This change uses the statement cache to lock the threads to using a single connection ID instead of each not being able to see each other. This code only runs in the fixture setup and teardown so it does not affect real production databases. When a transaction is opened we set `lock_thread` to `Thread.current` so we can keep track of which connection the thread is using. When we rollback the transaction we unlock the thread and then there will be no left-over data in the database because the transaction will roll back the correct connections. [ Eileen M. Uchitelle, Matthew Draper ]
* | Add `default_index_type?` to the generic schema dumper doesn't have the ↵Ryuta Kamizono2017-02-141-0/+4
| | | | | | | | knowledge about an index type
* | Deprecate `supports_primary_key?`Ryuta Kamizono2017-02-121-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | `supports_primary_key?` was added to determine if `primary_key` is implemented in the adapter in f060221. But we already use `primary_key` without `supports_primary_key?` (207f266, 5f3cf42) and using `supports_primary_key?` has been removed in #1318. This means that `supports_primary_key?` is no longer used in the internal and Active Record doesn't work without `primary_key` is implemented (all adapters must implement `primary_key`). Closes #27977
* | Merge pull request #26378 from ↵Jeremy Daer2017-02-061-5/+5
|\ \ | |/ |/| | | | | kamipo/decouple_building_arel_ast_for_uniqueness_validator Decouple the building Arel ASTs for uniqueness validator
| * Add `:nodoc:` to `case_sensitive_comparison` and `case_insensitive_comparison`Ryuta Kamizono2017-01-201-2/+2
| | | | | | | | These methods are obviously for internal use.
| * Decouple the building Arel ASTs for uniqueness validatorRyuta Kamizono2016-12-251-3/+3
| | | | | | | | | | | | Currently uniqueness validator is coupled with building Arel ASTs. This commit extracts `WhereClauseFactory#build_for_case_sensitive` for decouple the building Arel ASTs.
* | Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+Ryuta Kamizono2017-02-011-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/ Declare virtual columns with `t.virtual name, type: …, as: "expression"`. Pass `stored: true` to persist the generated value (false by default). Example: create_table :generated_columns do |t| t.string :name t.virtual :upper_name, type: :string, as: "UPPER(name)" t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true t.index :name_length # May be indexed, too! end Closes #22589
* | SQLite: Foreign Key SupportRyuta Kamizono2017-01-171-0/+6
| | | | | | | | https://www.sqlite.org/foreignkeys.html
* | Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-121-3/+3
| | | | | | | | (I personally prefer writing one string in one line no matter how long it is, though)
* | Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-281-3/+3
|/ | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* Privatize unneededly protected methods in Active RecordAkira Matsuda2016-12-241-13/+13
|
* fix QueryCache nil dupRichard Monette2016-12-151-1/+6
| | | | | | | | | | | | | | make sql statements frozen dup if arel is not our string expect runtime error dont wrap runtime error in invalid log errors will now be treated as runtime errors update changelog
* Refactor column initialization into `new_column_from_field`Kir Shatrov2016-11-111-0/+8
| | | | that accepts results of SHOW FIELDS
* Merge pull request #26909 from matthewd/query-cache-connectionMatthew Draper2016-11-061-3/+3
|\ | | | | Clear query cache during checkin, instead of an execution callback
| * Clear query cache during checkin, instead of an execution callbackMatthew Draper2016-10-271-3/+3
| | | | | | | | | | | | | | It doesn't make sense for the query cache to persist while a connection moves through the pool and is assigned to a new thread. [Samuel Cochran & Matthew Draper]
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|/
* Revert "Extract `PredicateBuilder::CaseSensitiveHandler`"Sean Griffin2016-08-311-6/+6
| | | | | | | | | This reverts commit 3a1f6fe7b4a70bf0698b0684dd48ac712c6883b6. This commit takes the code in a direction that I am looking to avoid. The predicate builder should be purely concerned with AST construction as it matters to methods like `where`. Things like case sensitivity should continue to be handled elsewhere.