aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #17822 from kamipo/refactor_visit_change_column_definitionRafael Mendonça França2015-01-024-16/+14
|\ | | | | Refactor `visit_ChangeColumnDefinition`
| * Refactor `visit_ChangeColumnDefinition`Ryuta Kamizono2015-01-032-11/+9
| | | | | | | | `visit_ChangeColumnDefinition` is the same "CHANGE column_name " + `visit_ColumnDefinition(o)`.
| * Add default value for `create_table_definition`Ryuta Kamizono2015-01-033-5/+5
| | | | | | | | | | In most cases, `create_table_definition` called by table_name (the first argument) only.
* | 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-027-9/+17
|\ \ | | | | | | | | | Clear query cache on rollback
| * | Restore query cache on rollbackFlorian Weingarten2014-12-017-9/+17
| | |
* | | Merge pull request #18228 from kamipo/correctly_dump_primary_keyRafael Mendonça França2015-01-024-0/+37
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Improve a dump of the primary key support. Conflicts: activerecord/CHANGELOG.md
| * | | Improve a dump of the primary key support.Ryuta Kamizono2014-12-294-0/+37
| | | | | | | | | | | | | | | | If it is not a default primary key, correctly dump the type and options.
* | | | Merge pull request #18067 from ↵Rafael Mendonça França2015-01-021-0/+28
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | kamipo/format_datetime_string_according_to_precision Format the datetime string according to the precision of the datetime field. Conflicts: activerecord/CHANGELOG.md
| * | | | Format the datetime string according to the precision of the datetime field.Ryuta Kamizono2015-01-021-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Incompatible to rounding behavior between MySQL 5.6 and earlier. In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`: http://bugs.mysql.com/bug.php?id=68760
| * | | | Allow precision option for MySQL datetimes.Ryuta Kamizono2015-01-021-0/+12
|/ / / /
* | | | Merge pull request #18080 from korbin/fix_reaping_frequency_configurationRafael Mendonça França2015-01-021-1/+1
|\ \ \ \ | | | | | | | | | | | | | | | Fix issue with reaping_frequency type.
| * | | | fix issue with reaping_frequency typekorbin2014-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using DATABASE_URL to configure ActiveRecord, :reaping_frequency does not get converted from a string to a numeric value. This value is eventually passed to 'sleep' and must be numeric to avoid exceptions. This commit converts :reaping_frequency to a float when present.
* | | | | 💣 I forgot to commit the arity changeSean Griffin2015-01-011-1/+1
| | | | |
* | | | | Don't load an entire table into memory to copy it on SQLiteSean Griffin2015-01-011-15/+4
| | | | | | | | | | | | | | | | | | | | SQL has mechanisms we can use to copy data from one table into another.
* | | | | Stop passing the column to the connection adapter when quoting defaultsSean Griffin2015-01-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The column is no longer used for anything besides type casting, which is what we're trying to remove from the column entirely.
* | | | | Extract the index length validation to a auxiliar methodRafael Mendonça França2014-12-303-9/+12
| | | | |
* | | | | Raise a better exception for renaming long indexes for mysql adaptersYasuo Honda2014-12-301-0/+3
| | | | |
* | | | | Merge pull request #17680 from larskanis/fix_bytea_change_detectionSean Griffin2014-12-301-0/+1
|\ \ \ \ \ | | | | | | | | | | | | PostgreSQL, Fix change detection caused by superfluous bytea unescaping
| * | | | | PostgreSQL, Fix change detection caused by wrong data for bytea unescaping.Lars Kanis2014-12-291-0/+1
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This showed up when running BinaryTest#test_load_save with the more restrictive input string handling of pg-0.18.0.pre20141117110243.gem . Bytea values sent to the server are in binary format, but are returned back as escaped text. To fulfill the assumption that type_cast_from_database(type_cast_for_database(binary)) == binary we unescape only, if the value was really received from the server.
* / | | | Ensures that primary_key method will return nil when multi-pkArthur Neves2014-12-302-8/+7
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | When table has a composite primary key, the `primary_key` method for sqlite3 and postgresql was only returning the first field of the key. Ensures that it will return nil instead, as AR dont support composite pks.
* | | | Minor documentation edits [ci skip]Robin Dupret2014-12-281-6/+5
| | | |
* | | | Add bigint primary key support for MySQL.Ryuta Kamizono2014-12-283-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: create_table :foos, id: :bigint do |t| end
* | | | Support for any type primary key.Ryuta Kamizono2014-12-282-10/+5
| | | |
* | | | add autoload for `ForeignKeyDefinition`.Yves Senn2014-12-271-0/+1
| | | | | | | | | | | | | | | | /cc @sgrif
* | | | reduce duplication in `ConnectionAdapters::Table` docs. [ci skip]Yves Senn2014-12-271-27/+38
| | | | | | | | | | | | | | | | | | | | | | | | Most of the documentation very closely mirrors the matching docs from `SchemaStatements`. I reduced duplicated copy and added links to the underlying methods for the user to follow.
* | | | Refactor `PostgreSQL::TableDefinition#primary_key`Ryuta Kamizono2014-12-271-4/+2
| | | | | | | | | | | | | | | | | | | | Because call the `column` method and set the `options[:primary_key]` is handled at `super`, here need only treat the `options[:default]`.
* | | | Correctly ignore `case_sensitive` for UUID uniqueness validationSean Griffin2014-12-262-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I think we should deprecate this behavior and just error if you tell us to do a case insensitive comparison for types which are not case sensitive. Partially reverts 35592307 Fixes #18195
* | | | Refactor a common class to reduce the duplication for `references`Sean Griffin2014-12-232-59/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code for `TableDefinition#references` and `SchemaStatements#add_reference` were almost identical both structurally, and in terms of domain knowledge. This removes that duplication into a common class, using the `Table` API as the expected interface of its collaborator.
* | | | Fix connection leak when a thread checks in additional connections.Matt Jones2014-12-231-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code in `ConnectionPool#release` assumed that a single thread only ever holds a single connection, and thus that releasing a connection only requires the owning thread_id. There is a trivial counterexample to this assumption: code that checks out additional connections from the pool in the same thread. For instance: connection_1 = ActiveRecord::Base.connection connection_2 = ActiveRecord::Base.connection_pool.checkout ActiveRecord::Base.connection_pool.checkin(connection_2) connection_3 = ActiveRecord::Base.connection At this point, connection_1 has been removed from the `@reserved_connections` hash, causing a NEW connection to be returned as connection_3 and the loss of any tracking info on connection_1. As long as the thread in this example lives, connection_1 will be inaccessible and un-reapable. If this block of code runs more times than the size of the connection pool in a single thread, every subsequent connection attempt will timeout, as all of the available connections have been leaked. Reverts parts of 9e457a8654fa89fe329719f88ae3679aefb21e56 and essentially all of 4367d2f05cbeda855820e25a08353d4b7b3457ac
* | | | Add `foreign_key` as an option to `references` for `change_table`Sean Griffin2014-12-222-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This has the same comments as 9af90ffa00ba35bdee888e3e1ab775ba0bdbe72c, however it affects the `add_reference` method, and `t.references` in the context of a `change_table` block. There is a lot of duplication of code between creating and updating tables. We should re-evaluate the structure of this code from a high level so changes like this don't need to be made in two places. (Note to self)
* | | | Convert `add_references` to use kwargsSean Griffin2014-12-221-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | While we still aren't accepting PRs that only make changes like this, it's fine when we're actively working on a method if it makes our lives easier.
* | | | Add a `foreign_key` option to `references` while creating the tableSean Griffin2014-12-222-5/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than having to do: create_table :posts do |t| t.references :user end add_foreign_key :posts, :users You can instead do: create_table :posts do |t| t.references :user, foreign_key: true end Similar to the `index` option, you can also pass a hash. This will be passed as the options to `add_foreign_key`. e.g.: create_table :posts do |t| t.references :user, foreign_key: { primary_key: :other_id } end is equivalent to create_table :posts do |t| t.references :user end add_foreign_key :posts, :users, primary_key: :other_id
* | | | Convert `references` to kwargsSean Griffin2014-12-221-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | While we aren't taking PRs with these kinds of changes just yet, they are fine if we're actively working on the method and it makes things easier.
* | | | Correctly handle limit on int4 and int8 types in PGSean Griffin2014-12-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PG doesn't register it's types using the `int(4)` format that others do. As such, if we alias `int8` to the other integer types, the range information is lost. This is fixed by simply registering it separately. The other option (which I specifically chose to avoid) is to pass the information of the original type that was being aliased as an argument. I'd rather avoid that, since an alias should truly be treated the same. If we need different behavior for a different type, we should explicitly register it with that, and not have a conditional based on aliasing. Fixes #18144 [Sean Griffin & ysbaddaden]
* | | | `force: :cascade` to recreate tables referenced by foreign-keys.Yves Senn2014-12-193-3/+12
| | | |
* | | | Relax the UUID regexGodfrey Chan2014-12-181-9/+2
|/ / / | | | | | | | | | | | | | | | | | | | | | Apparently PG does not validate against RFC 4122. The intent of the original patch is just to protect against PG errors (which potentially breaks txns, etc) because of bad user input, so we shouldn't try any harder than PG itself. Closes #17931
* | | Merge pull request #17793 from kamipo/fix_undesirable_range_errorSean Griffin2014-12-111-5/+16
|\ \ \ | | | | | | | | Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.
| * | | Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.Ryuta Kamizono2014-12-121-5/+16
| | | |
* | | | Refactor `quoted_date`Ryuta Kamizono2014-12-114-25/+13
|/ / / | | | | | | | | | Move microseconds formatting to `AbstractAdapter`.
* | | Revert to 4.1 behavior for casting PG arraysSean Griffin2014-12-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The user is able to pass PG string literals in 4.1, and have it converted to an array. This is also possible in 4.2, but it would remain in string form until saving and reloading, which breaks our `attr = save.reload.attr` contract. I think we should deprecate this in 5.0, and only allow array input from user sources. However, this currently constitutes a breaking change to public API that did not go through a deprecation cycle.
* | | minor sentences fixesNeeraj Singh2014-12-071-3/+3
| | |
* | | Correctly respect subtypes for PG arrays and rangesSean Griffin2014-12-052-10/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The type registration was simply looking for the OID, and eagerly fetching/constructing the sub type when it was registered. However, numeric types have additional parameters which are extracted from the actual SQL string of the type during lookup, and can have their behavior change based on the result. We simply need to use the block form of registration, and look up the subtype lazily instead. Fixes #17935
* | | Failure to rollback t.timestamps when within a change_table migrationnoam2014-12-033-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running the following migration: change_table(:table_name) { |t| t/timestamps } The following error was produced: wrong number of arguments (2 for 1) .... /connection_adapters/abstract/schema_statements.rb:851:in `remove_timestamps' This is due to `arguments` containing an empty hash as its second argument.
* | | no need to pass native_database_types aroundYves Senn2014-12-022-5/+5
| | |
* | | Fix value extracted from negative integers for PostgreSQL.Guo Xiang Tan2014-12-011-1/+1
| | | | | | | | | | | | Fixes: https://github.com/rails/rails/issues/17856.
* | | Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-296-17/+11
| | |
* | | Merge pull request #17799 from kamipo/refactor_add_column_optionsRafael Mendonça França2014-11-282-6/+14
|\ \ \ | | | | | | | | Refactor `add_column_options!`, to move the quoting of default value for :uuid in `quote_value`.
| * | | Rename to `quote_default_expression` from `quote_value`Ryuta Kamizono2014-11-282-3/+3
| | | |