aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Use tt in doc for ActiveRecord [ci skip]Yoshiyuki Hirano2017-08-271-2/+2
|
* Merge pull request #30337 from kamipo/refactor_schema_dumperRyuta Kamizono2017-08-2412-49/+47
|\ | | | | Refactor `SchemaDumper` to make it possible to adapter specific customization
| * Refactor `SchemaDumper` to make it possible to adapter specific customizationRyuta Kamizono2017-08-2212-35/+48
| | | | | | | | | | | | | | 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.
| * Remove deprecated `#migration_keys`Ryuta Kamizono2017-08-223-15/+0
| |
* | Merge pull request #30360 from gcourtemanche/transaction_timedoutRafael França2017-08-221-0/+3
|\ \ | |/ |/| Add TransactionTimeout for MySQL error code 1205
| * Add TransactionTimeout for MySQL error code 1205Gabriel Courtemanche2017-08-221-0/+3
| |
* | Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-226-7/+7
|/
* Prevent extra `SET time zone` in `configure_connection` (#28413)Ryuta Kamizono2017-08-211-6/+8
| | | | | | | | `SET time zone 'value'` is an alias for `SET timezone TO 'value'`. https://www.postgresql.org/docs/current/static/sql-set.html So if `variables["timezone"]` is specified, it is enough to `SET timezone` once.
* Require "active_support/core_ext/hash/compact" for `compact!`Ryuta Kamizono2017-08-211-0/+2
|
* Place `update_table_definition` consistently in `SchemaStatements`Ryuta Kamizono2017-08-216-12/+12
|
* Don't expose `prepare_column_options`Ryuta Kamizono2017-08-213-52/+30
| | | | | This is only used for the internal `column_spec` and `column_spec_for_primary_key`.
* Register integer types limit correctly for postgresql adapter (#26386)Ryuta Kamizono2017-08-201-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | currently integer types extracts the `limit` from `sql_type`. But the lookup key of type map is the `oid` in postgresql adapter. So in most case `sql_type` is passed to `extract_limit` as `""` and `limit` is extracted as `nil`. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L445 In mysql2 adapter, `limit` is registered correctly without extracting from `sql_type`. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L678-L682 Postgresql adapter should also be registered correctly. ``` ruby conn = ActiveRecord::Base.connection conn.select_all("SELECT 1::smallint, 2::integer, 3::bigint").column_types.map do |name, type| [name, type.limit] end ``` Before: ``` ruby # => [["int2", nil], ["int4", nil], ["int8", nil]] ``` After: ``` ruby # => [["int2", 2], ["int4", 4], ["int8", 8]] ```
* Restore the ability that SQL with binds for `insert`, `update`, and `delete` ↵Ryuta Kamizono2017-08-181-6/+6
| | | | | | | | (#29944) Since 213796f, it was lost the ability that SQL with binds for `insert`, `update`, and `delete` (like `select_all`). This restores the ability because `insert`, `update`, and `delete` are public API, so it should not be removed without deprecation.
* Restore `to_sql` to return only SQL (#29945)Ryuta Kamizono2017-08-185-11/+14
| | | | Because `to_sql` is public API. I introduced `to_sql_and_binds` internal API to return SQL and binds.
* Fix RDoc formatting: `+` doesn't work with `@`ohbarye2017-08-111-5/+5
| | | | | | | | | | | | | | refs: https://github.com/rails/rails/pull/30161 ``` $ echo "+@size+" | rdoc --pipe <p>+@size+</p> $ echo "<tt>@size</tt>" | rdoc --pipe <p><code>@size</code></p> ``` [ci skip]
* Start `@reaper.run` after connection pool initializedRyuta Kamizono2017-08-111-2/+3
| | | | | | | Otherwise `ConnectionPool#reap` may run before `@connections` has initialized. https://travis-ci.org/rails/rails/jobs/263037427#L888-L890
* Merge pull request #30108 from yui-knk/require_concurrent_mapRafael França2017-08-081-0/+2
|\ | | | | Add missed `require`
| * Add missed `require`yui-knk2017-08-071-0/+2
| | | | | | | | | | `ActiveRecord::ConnectionAdapters::QueryCache::ConnectionPoolConfiguration` depends on `Concurrent::Map`.
* | [ci skip] Postgres --> PostgreSQLRyuta Kamizono2017-08-081-1/+1
|/
* Fix all rubocop violationsRafael Mendonça França2017-08-031-2/+2
|
* Change http postgresql.org links to https [ci skip]yuuji.yaginuma2017-07-303-6/+6
| | | | | It seems that it accepts only HTTPS connections. Ref: https://github.com/postgres/postgres/commit/7f77cbd996855a06fb742ea11adbe55c42b48fe2
* Use `predicate_builder.build_bind_attribute` wherever possibleRyuta Kamizono2017-07-282-4/+4
| | | | For less duplicated code.
* Clarify add_column limit documentationLisa Ugray2017-07-251-0/+1
| | | | | The limit option is ignored by PostgreSQL and may be ignored by 3rd party backends. Make this clear in the docs. Fixes #29922.
* Fix test failures when prepared statements are disabledSean Griffin2017-07-242-3/+26
| | | | | | | | | This also reverts the change to enable prepared statements by default on MySQL (though I suspect we could enable them and it'd be great). This change brings back a collector closer to the old `Bind` collector in Arel. However, this one lives in AR, since this is an AR specific need. Additionally, we only use it for statement caching, since the new substitute collector in Arel is higher performance for most cases.
* Fix build failures on MySQLSean Griffin2017-07-242-2/+2
| | | | | | There's an actual bug in 213796fb4936dce1da2f0c097a054e1af5c25c2c around prepared statements being disabled. I'm looking into it, but in the mean time this gets the build green so it doesn't block other PRs
* Refactor Active Record to let Arel manage bind paramsSean Griffin2017-07-248-62/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #29870 from kamipo/use_true_false_literalsSean Griffin2017-07-222-14/+4
|\ | | | | Use `TRUE` and `FALSE` boolean literals for MySQL
| * Use `TRUE` and `FALSE` boolean literals for MySQLRyuta Kamizono2017-07-202-14/+6
| | | | | | | | | | | | Since #29699, abstract boolean serialization has been changed to use `TRUE` and `FALSE` literals. MySQL also support the literals. So we can use the abstract boolean serialization even for MySQL.
* | Merge pull request #29869 from kamipo/make_type_map_to_privateRafael França2017-07-214-17/+16
|\ \ | | | | | | 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-204-17/+16
| |/ | | | | | | | | | | | | `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-1969-0/+138
|/
* Fix type casting a time for MariaDBRyuta Kamizono2017-07-191-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Context #24542. Since 8ebe1f2, it has lost stripping date part for a time value. But I confirmed it is still needed even if MariaDB 10.2.6 GA. MariaDB 10.2.6, `prepared_statements: true`: ``` % ARCONN=mysql2 be ruby -w -Itest test/cases/time_precision_test.rb -n test_formatting_time_according_to_precision Using mysql2 Run options: -n test_formatting_time_according_to_precision --seed 37614 F Failure: TimePrecisionTest#test_formatting_time_according_to_precision [test/cases/time_precision_test.rb:53]: Failed assertion, no message given. bin/rails test test/cases/time_precision_test.rb:46 Finished in 0.040279s, 24.8268 runs/s, 24.8268 assertions/s. 1 runs, 1 assertions, 1 failures, 0 errors, 0 skips ```
* Merge pull request #29785 from ↵Sean Griffin2017-07-181-0/+1
|\ | | | | | | | | cswilliams/rescue_postgres_connection_errors_on_dealloc Catch postgres connection errors when trying to dealloc
| * Catch postgres connection errors when trying to dealloc the statement poolChris Williams2017-07-131-0/+1
| | | | | | | | | | | | connection_active? will sometimes return true when the connection is actually dead/disconnected (see #3392 for a discussion of why this is). When this happens, a query is run on the dead connection which causes various postgres connection errors to be raised. This fix catches any such errors and ignores them. Closes #29760
* | Don't convert dates to strings when using prepared statements in mysqlSean Griffin2017-07-181-0/+8
| | | | | | | | | | | | | | | | Dates are able to be natively handled by the mysql2 gem. libmysql (and the wire protocol) represent each portion of the date as an integer, which is significantly faster to encode and decode. By passing the Ruby date objects through directly, we can save a good bit of time and memory.
* | Set `represent_boolean_as_integer` via `configuration`yuuji.yaginuma2017-07-161-1/+1
| |
* | Fix boolean column migration scriptyuuji.yaginuma2017-07-131-1/+1
|/
* Merge pull request #29699 from lugray/represent_boolean_as_integerMatthew Draper2017-07-123-4/+38
|\ | | | | Change sqlite3 boolean serialization to use 1 and 0
| * Change sqlite3 boolean serialization to use 1 and 0Lisa Ugray2017-07-113-4/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Abstract boolean serialization has been using 't' and 'f', with MySQL overriding that to use 1 and 0. This has the advantage that SQLite natively recognizes 1 and 0 as true and false, but does not natively recognize 't' and 'f'. This change in serialization requires a migration of stored boolean data for SQLite databases, so it's implemented behind a configuration flag whose default false value is deprecated. The flag itself can be deprecated in a future version of Rails. While loaded models will give the correct result for boolean columns without migrating old data, where() clauses will interact incorrectly with old data. While working in this area, also change the abstract adapter to use `"TRUE"` and `"FALSE"` as quoted values and `true` and `false` for unquoted. These are supported by PostreSQL, and MySQL remains overriden.
* | [Action Record] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|/
* Merge pull request #29655 from kirs/frozen-friendly-ap-arMatthew Draper2017-07-101-1/+2
|\ | | | | Prepare AP and AR to be frozen string friendly
| * Prepare AP and AR to be frozen string friendlyKir Shatrov2017-07-061-1/+2
| |
* | Merge pull request #29715 from reverbdotcom/ptd/fix-invalid-uuidsMatthew Draper2017-07-091-1/+1
|\ \ | | | | | | Don't allow uuids with orphan curly braces
| * | Don't allow uuids with orphan curly bracespdebelak2017-07-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The uuid validation regex was allowing uuids to have a single leading curly brace or single trailing curly brace. Saving with such a uuid would cause Postgres to generate an exception even though the record seemed valid. With this change, the regex requires both a leading *and* a trailing curly brace or neither to be valid.
* | | Merge pull request #29692 from fimmtiu/avoid-translating-non-database-exceptionsMatthew Draper2017-07-091-2/+4
|\ \ \ | | | | | | | | Don't translate non-database exceptions.
| * | | 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 pull request #29706 from ↵Matthew Draper2017-07-091-1/+1
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | kamipo/use_information_schema_to_extract_expression Use `information_schema` to extract `generation_expression` for MariaDB
| * | | | Use `information_schema` to extract `generation_expression` for MariaDBRyuta Kamizono2017-07-071-1/+1
| | |/ / | |/| | | | | | | | | | | | | | | | | | Since MariaDB 10.2.5, `information_schema` supports Virtual Columns. Fixes #29670.
* / | | Fix default `CURRENT_TIMESTAMP` in schema dumping for MariaDB 10.2Ryuta Kamizono2017-07-071-2/+2
|/ / / | | | | | | | | | | | | | | | | | | | | | Since MariaDB 10.2, `CURRENT_TIMESTAMP` is shown as a function (`current_timestamp()`). Fix matching column default to address that case. Fixes #29698.
* / / Fix extracting MariaDB versionRyuta Kamizono2017-07-071-2/+6
|/ / | | | | | | | | | | Currently `version` method always returns `5.5.5` because the `full_version` is `5.5.5-10.x.y-MariaDB...` since MariaDB 10.x. It should be ignored if the prefix is `5.5.5-`.