aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
* AR: translate_exception_class() no longer logs error.Paul Annesley2015-02-241-1/+0
|
* Allow `:precision` option for time type columnsRyuta Kamizono2015-02-201-0/+5
|
* Revert "Allow `:precision` option for time type columns"Sean Griffin2015-02-171-5/+0
| | | | | | | | | | This reverts commit 1502caefd30b137fd1a0865be34c5bbf85ba64c1. The test suite for the mysql adapter broke when this commit was used with MySQL 5.6. Conflicts: activerecord/CHANGELOG.md
* Allow `:precision` option for time type columnsRyuta Kamizono2015-02-121-0/+5
|
* Refactor microsecond precision to be database agnosticSean Griffin2015-02-101-21/+16
| | | | | | | | | | The various databases don't actually need significantly different handling for this behavior, and they can achieve it without knowing about the type of the object. The old implementation was returning a string, which will cause problems such as breaking TZ aware attributes, and making it impossible for the adapters to supply their logic for time objects.
* rm `Type#text?`Sean Griffin2015-02-071-1/+10
| | | | | | | | | | | | | | | | This predicate was only to figure out if it's safe to do case insensitive comparison, which is only a problem on PG. Turns out, PG can just tell us whether we are able to do it or not. If the query turns out to be a problem, let's just replace that method with checking the SQL type for `text` or `character`. I'd rather not burden the type objects with adapter specific knowledge. The *real* solution, is to deprecate this behavior entirely. The only reason we need it is because the `:case_sensitive` option for `validates_uniqueness_of` is documented as "this option is ignored for non-strings". It makes no sense for us to do that. If the type can't be compared in a case insensitive way, the user shouldn't tell us to do case insensitive comparison.
* rm `Column#cast_type`Sean Griffin2015-02-031-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The type from the column is never used, except when being passed to the attributes API. While leaving the type on the column wasn't necessarily a bad thing, I worry that it's existence there implies that it is something which should be used. During the design and implementation process of the attributes API, there have been plenty of cases where getting the "right" type object was hard, but I had easy access to the column objects. For any contributor who isn't intimately familiar with the intents behind the type casting system, grabbing the type from the column might easily seem like the "correct" thing to do. As such, the goal of this change is to express that the column is not something that should be used for type casting. The only places that are "valid" (at the time of this commit) uses of acquiring a type object from the column are fixtures (as the YAML file is going to mirror the database more closely than the AR object), and looking up the type during schema detection to pass to the attributes API Many of the failing tests were removed, as they've been made obsolete over the last year. All of the PG column tests were testing nothing beyond polymorphism. The Mysql2 tests were duplicating the mysql tests, since they now share a column class. The implementation is a little hairy, and slightly verbose, but it felt preferable to going back to 20 constructor options for the columns. If you are git blaming to figure out wtf I was thinking with them, and have a better idea, go for it. Just don't use a type object for this.
* Properly lookup the limit for bigintSean Griffin2015-02-021-1/+6
| | | | Fixes #18787.
* Remove Relation#bind_paramsSean Griffin2015-01-271-1/+1
| | | | | | | | `bound_attributes` is now used universally across the board, removing the need for the conversion layer. These changes are mostly mechanical, with the exception of the log subscriber. Additional, we had to implement `hash` on the attribute objects, so they could be used as a key for query caching.
* Stop passing a column to `quote` when prepared statements are turned offSean Griffin2015-01-101-1/+2
| | | | | | | I'm planning on deprecating the column argument to mirror the deprecation in [arel]. [arel]: https://github.com/rails/arel/commit/6160bfbda1d1781c3b08a33ec4955f170e95be11
* Fix count on a separate connection (fixes #18359)brainopia2015-01-081-1/+1
| | | | | | | | Previosly count and other AR calculations would convert column_name_for_operation to sql on a default Arel::Table.engine (AR::Base) connection. That could lead to trouble if current model has a connection to a different adapter or Base connection is inaccessible.
* Change the default `null` value for `timestamps` to `false`Rafael Mendonça França2015-01-041-1/+0
|
* Merge pull request #8547 from printercu/patch-1Rafael Mendonça França2015-01-021-1/+6
|\ | | | | | | | | | | | | | | fix for messages in invalid encoding from db-drivers Conflicts: activerecord/lib/active_record/connection_adapters/abstract_adapter.rb activerecord/test/cases/connection_adapters/abstract_adapter_test.rb
| * fix for messages in invalid encoding from db-driversMax Melentiev2013-12-071-1/+5
| |
* | Merge pull request #17820 from fw42/restore_query_cache_on_rollbackRafael Mendonça França2015-01-021-3/+0
|\ \ | | | | | | | | | Clear query cache on rollback
| * | Restore query cache on rollbackFlorian Weingarten2014-12-011-3/+0
| | |
* | | add autoload for `ForeignKeyDefinition`.Yves Senn2014-12-271-0/+1
| | | | | | | | | | | | /cc @sgrif
* | | Refactor `quoted_date`Ryuta Kamizono2014-12-111-0/+10
|/ / | | | | | | Move microseconds formatting to `AbstractAdapter`.
* | ConnectionAdapter#substitute_at is technically public API...Sean Griffin2014-11-211-1/+1
| | | | | | | | We can't change the signature without a deprecation cycle.
* | synchronize code and docs for `timestamps` and `add_timestamps`.Yves Senn2014-11-201-0/+1
| | | | | | | | | | | | | | | | This makes the following changes: * warn if `:null` is not passed to `add_timestamps` * `timestamps` method docs link to `add_timestamps` docs * explain where additional options go * adjust examples to include `null: false` (to prevent deprecation warnings)
* | Remove the unused second argument to `substitute_at`Sean Griffin2014-11-171-2/+2
| | | | | | | | Oh hey, we got to remove some code because of that!
* | rm `reorder_bind_params`Sean Griffin2014-11-171-1/+1
| | | | | | | | | | | | Arel handles this for us automatically. Updated tests, as BindParam is no longer a subclass of SqlLiteral. We should remove the second argument to substitute_at entirely, as it's no longer used
* | Remove unneeded autoloadRafael Mendonça França2014-11-031-4/+1
| |
* | Correctly cast calculation results on PGSean Griffin2014-11-011-0/+4
| | | | | | | | | | MySQL reports the column name as `"MAX(developer_id)"`. PG will report it as `"max"`
* | Remove redundant substitute index when constructing bind valuesMelanie Gilman2014-10-311-1/+1
| | | | | | | | | | | | We end up re-ordering them either way when we construct the Arel AST (in order to deal with rewhere, etc), so we shouldn't bother giving it a number in the first place beforehand.
* | introduce `connection.supports_views?` and basic view tests.Yves Senn2014-09-091-0/+5
| | | | | | | | | | | | | | `AbstractAdapter#supports_views?` defaults to `false` so we have to turn it on in adapter subclasses. Currently the flag only controls test execution. /cc @yahonda
* | Freeze ADAPTER_NAME in adaptersAbdelkader Boudih2014-09-051-1/+2
| |
* | Replace ClosedTransaction with NullTransactionArthur Neves2014-07-311-1/+1
| |
* | savepoint_name should return nil for non-savepoint transactionsArthur Neves2014-07-281-3/+1
| | | | | | | | Also add test to assets the savepoint name
* | Transactions refactoringArthur Neves2014-07-281-0/+1
| | | | | | | | | | | | | | Add a transaction manager per connection, so it can controls the connection responsibilities. Delegate transaction methods to transaction_manager
* | Remove finishing? method from transaction.Arthur Neves2014-07-241-1/+3
| | | | | | | | | | | | | | | | | | | | The finishing variable on the transaction object was a work-around for the savepoint name, so after a rollback/commit the savepoint could be released with the previous name. related: 9296e6939bcc786149a07dac334267c4035b623a 60c88e64e26682a954f7c8cd6669d409ffffcc8b
* | Always pass a column with a type object to quoteSean Griffin2014-06-281-2/+2
| | | | | | | | | | | | | | | | The only case where we got a column that was not `nil`, but did not respond to `cast_type` was when type casting the default value during schema creation. We can look up the cast type, and add that object to the column definition. Will allow us to consistently rely on the type objects for type casting in all directions.
* | fk: `add_foreign_key` and `remove_foreign_key` for PostgreSQL adapter.Yves Senn2014-06-261-0/+5
| |
* | have an actual `NullColumn` object and update docs accordingly.Yves Senn2014-06-041-1/+4
| | | | | | | | | | | | Follow up to #15438 and #15502. /cc @sgrif
* | Ensure we always use instances of the adapter specific column classSean Griffin2014-05-281-0/+4
| | | | | | | | | | | | - Create a consistent API across adapters for building new columns - Use it for custom properties so we don't get `UndefinedMethodError`s in stuff I'm implementing elsewhere.
* | Keep closer to other methods that touch @transactionArthur Neves2014-05-281-4/+0
| |
* | Move types to the top level `ActiveRecord` namespaceSean Griffin2014-05-271-1/+1
| | | | | | | | | | `ActiveRecord::ConnectionAdapters::Type::Value` => `ActiveRecord::Type::Value`
* | Deprecate decimal columns being automatically treated as integersSean Griffin2014-05-271-0/+1
| | | | | | | | | | | | With ActiveRecord::Properties, we now have a reasonable path for users to continue to keep this behavior if they want it. This is an edge case that has added a lot of complexity to the code base.
* | Remove special case in schema dumper for decimal without scaleSean Griffin2014-05-231-1/+1
| |
* | Push limit to type objectsSean Griffin2014-05-221-15/+28
| | | | | | | | | | Columns and injected types no longer have any conditionals based on the format of SQL type strings! Hooray!
* | Push precision to type objectsSean Griffin2014-05-221-2/+7
| |
* | Push scale to type objectsSean Griffin2014-05-221-2/+11
| | | | | | | | | | | | Ideally types will be usable without having to specify a sql type string, so we should keep the information related to parsing them on the adapter or another object.
* | Remove :timestamp column typeSean Griffin2014-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The `:timestamp` type for columns is unused. All database adapters treat them as the same database type. All code in `ActiveRecord` which changes its behavior based on the column's type acts the same in both cases. However, when the type is passed to code that checks for the `:datetime` type, but not `:timestamp` (such as XML serialization), the result is unexpected behavior. Existing schema definitions will continue to work, and the `timestamp` type is transparently aliased to `datetime`.
* | Delegate `Column#type` to the injected type objectSean Griffin2014-05-191-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The decision to wrap type registrations in a proc was made for two reasons. 1. Some cases need to make an additional decision based on the type (e.g. a `Decimal` with a 0 scale) 2. Aliased types are automatically updated if they type they point to is updated later. If a user or another adapter decides to change the object used for `decimal` columns, `numeric`, and `number` will automatically point to the new type, without having to track what types are aliased explicitly. Everything else here should be pretty straightforward. PostgreSQL ranges had to change slightly, since the `simplified_type` method is gone.
* | Add a type object to Column constructorSean Griffin2014-05-171-0/+5
| | | | | | | | | | | | Part of #15134. In order to perform typecasting polymorphically, we need to add another argument to the constructor. The order was chosen to match the `oid_type` on `PostgreSQLColumn`.
* | Use the reader attribute rather than the instance var when possibleCarlos Antonio da Silva2014-05-041-2/+2
| |
* | Simplify unless conditional with ORCarlos Antonio da Silva2014-05-041-4/+2
| |
* | Convert column name to string only onceCarlos Antonio da Silva2014-05-041-1/+2
| |
* | refactor, move `column_for` to `AbstractAdapter` for better reuse.Yves Senn2014-05-041-0/+7
| |
* | push the collectors up to the abstract adapterAaron Patterson2014-04-091-0/+22
| |