aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* Prefer formatted number as schema version [ci skip]Ryuta Kamizono2017-08-211-1/+1
|
* 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-186-13/+15
| | | | Because `to_sql` is public API. I introduced `to_sql_and_binds` internal API to return SQL and binds.
* Merge pull request #30048 from yahonda/regexp_aware_schema_dumper_prefix_suffixRafael França2017-08-161-1/+3
|\ | | | | Allow `table_name_prefix` and `table_name_suffix` have `$`
| * Allow `table_name_prefix` and `table_name_suffix` have `$`Yasuo Honda2017-08-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL 5.7 and PostgreSQL 9.6 allow table identifiers have the dollar sign. * MySQL 5.7 https://dev.mysql.com/doc/refman/5.7/en/identifiers.html > Permitted characters in unquoted identifiers: > ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) * PostgreSQL 9.6 https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html > SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard. Address #30044 [Yasuo Honda & Ryuta Kamizono]
* | Add spaceJon Moss2017-08-161-1/+1
| | | | | | | | [ci skip]
* | Fix RuboCop offensesKoichi ITO2017-08-161-5/+6
| | | | | | | | And enable `context_dependent` of Style/BracesAroundHashParameters cop.
* | Merge pull request #30271 from ↵Rafael França2017-08-154-19/+14
|\ \ | | | | | | | | | | | | kamipo/through_scope_should_not_be_affected_by_scoping Through scope should not be affected by scoping
| * | Through scope should not be affected by scopingRyuta Kamizono2017-08-154-19/+14
| | | | | | | | | | | | | | | | | | Follow up of #29834. Fixes #30266.
* | | Don't expose `write_attribute_without_type_cast`Ryuta Kamizono2017-08-161-6/+5
|/ / | | | | | | | | | | `write_attribute_without_type_cast` is defined as a private method in `AttributeMethods::Write`, but `AttributeMethods::Dirty` overrode it as a public method. It should be kept the original visibility.
* | Merge pull request #30169 from awortham/awortham/awortham/fix-sql-distinct-bugRafael Mendonça França2017-08-141-0/+3
|\ \ | | | | | | | | | Ensure sum honors distinct on has_many through
| * | Ensure sum honors distinct on has_many throughAaron Wortham2017-08-141-0/+3
| | | | | | | | | | | | | | | | | | When using a has_many through relation and then summing an attribute the distinct was not being used. This will ensure that when summing an attribute, the number is only used once when distinct has been used.
* | | Merge pull request #30073 from yalab/fixture_binary_helperRafael França2017-08-141-0/+4
|\ \ \ | | | | | | | | Add `binary` helper method to fixtures.
| * | | Add `binary` helper method to fixtures.yalab2017-08-121-0/+4
| | | |
* | | | Merge pull request #30208 from kamipo/extract_primary_key_to_abstract_reflectionRafael França2017-08-141-8/+4
|\ \ \ \ | | | | | | | | | | Extract `primary_key` to `AbstractReflection`
| * | | | Extract `primary_key` to `AbstractReflection`Ryuta Kamizono2017-08-121-8/+4
| | | | |
* | | | | Merge pull request #27609 from kamipo/fix_association_primary_keyRafael França2017-08-142-4/+11
|\ \ \ \ \ | | | | | | | | | | | | Fix `reflection.association_primary_key` for `has_many` association
| * | | | | Fix `reflection.association_primary_key` for `has_many` associationsRyuta Kamizono2017-08-132-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is incorrect to treat `options[:primary_key]` as `association_primary_key` if `has_many` associations because the `:primary_key` means the column on the owner record, not on the association record. It will break `ids_reader` and `ids_writer`. ```ruby people(:david).essay_ids # => ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'essays.first_name' in 'field list': SELECT `essays`.first_name FROM `essays` WHERE `essays`.`writer_id` = 'David' ``` Fixes #14439.
* | | | | | Merge pull request #30229 from kamipo/allow_serialize_with_custom_coderRafael França2017-08-141-7/+4
|\ \ \ \ \ \ | | | | | | | | | | | | | | Allow `serialize` with a custom coder on `json` and `array` columns
| * | | | | | Allow `serialize` with a custom coder on `json` and `array` columnsRyuta Kamizono2017-08-131-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already have a test case for `serialize` with a custom coder in `PostgresqlHstoreTest`. https://github.com/rails/rails/blob/v5.1.3/activerecord/test/cases/adapters/postgresql/hstore_test.rb#L316-L335
* | | | | | | Merge pull request #30214 from kirs/uniqueness-scope-validatorRafael França2017-08-141-0/+4
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Check :scope input in Uniqueness validator
| * | | | | | | Check :scope input in Uniqueness validatorKir Shatrov2017-08-131-0/+4
| | |_|/ / / / | |/| | | | |
* | | | | | | Merge pull request #30236 from padi/find-each-example-updateRafael França2017-08-141-1/+6
|\ \ \ \ \ \ \ | |_|_|_|_|/ / |/| | | | | | Completes ActiveRecord::Batches.find_each example [ci skip]
| * | | | | | Completes ActiveRecord::Batches.find_each example [ci skip]Marc Rendl Ignacio2017-08-131-1/+6
| | |_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | The previous paragraph mentions that you can hand off the same processing queue to multiple workers. This completes the following example below it.
* | | | | | Merge pull request #30231 from kamipo/remove_unused_source_type_infoRafael França2017-08-141-10/+7
|\ \ \ \ \ \ | | | | | | | | | | | | | | Remove unused `source_type_info` in `RuntimeReflection`
| * | | | | | Remove unused `source_type_info` in `RuntimeReflection`Ryuta Kamizono2017-08-131-10/+7
| | |_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | `source_type_info` is only used for `constraints` in `PolymorphicReflection`.
* / | | | | Remove duplicated `join_id_for`Ryuta Kamizono2017-08-131-10/+2
|/ / / / / | | | | | | | | | | | | | | | The primary key on the owner record is abstracted as `join_foreign_key`.
* / / / / Delegate to `Enumerable#find` for `CollectionProxy`Ryuta Kamizono2017-08-132-17/+14
|/ / / / | | | | | | | | | | | | | | | | Since `Relation` includes `Enumerable`, it is enough to use `super` simply.
* / / / Remove duplicated `table_name`Ryuta Kamizono2017-08-121-8/+0
|/ / / | | | | | | | | | It can use `AbstractReflection#table_name` simply.
* | | Fix outdated comment for `Core::ClassMethods#===` [ci skip] (#30146)Ryuta Kamizono2017-08-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This comment was added at 97849de, but `AssociationProxy` and `test_triple_equality` was removed at 1644663. Currently the `===` is used for `test_decorated_polymorphic_where` that added at #11945. So I updated "association proxies" to "decorated models". And also, currently `Core::ClassMethods` appears in the doc. http://api.rubyonrails.org/classes/ActiveRecord/Core/ClassMethods.html But it looks like that the methods in the module is not public API. So I also added `# :nodoc:` to the module.
* | | Merge pull request #30126 from ↵Rafael França2017-08-113-12/+12
|\ \ \ | | | | | | | | | | | | | | | | chopraanmol1/support_for_has_many_and_has_one_for_where_relation Fixed query building when relation is passed for has one or has many association in where
| * | | Changed join_fk private method to join_foreign_key public methodchopraanmol12017-08-093-15/+11
| | | |
| * | | Currently if relation object are passed to where condition for has one or ↵chopraanmol12017-08-082-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | has many association wrong set of primary key and foreign key are selected. Changed code to use 'join' primary key and foreign key over 'association' primary key and foreign key.
* | | | Merge pull request #30159 from allcentury/dump-temp-file-permissionsRafael França2017-08-111-1/+1
|\ \ \ \ | | | | | | | | | | Use copy to preserve file permissions
| * | | | Use copy to preserve file permissionsAnthony Ross2017-08-091-1/+1
| | | | |
* | | | | Merge pull request #29720 from gaurish/ar_find_error_message_improvementRafael França2017-08-112-4/+6
|\ \ \ \ \ | | | | | | | | | | | | Return Not found Ids in ActiveRecord::NotFound
| * | | | | Return Not found Ids in ActiveRecord::NotFoundGaurish Sharma2017-07-292-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This builds on top of 15e2da656f41af0124f7577858536f3b65462ad5. now it also returns exact Ids which were not found which will be debugging simple.
* | | | | | Merge pull request #30193 from zverok/robust-postgres-duplicate-dbRafael França2017-08-111-1/+1
|\ \ \ \ \ \ | | | | | | | | | | | | | | More robust PostgreSQL database duplication check
| * | | | | | Update database duplication checkzverok2017-08-111-1/+1
| | | | | | |
* | | | | | | Specify `table.name` only when `scope.table` and `table` are different (#29058)Ryuta Kamizono2017-08-111-4/+12
| | | | | | | | | | | | | | | | | | | | | Fixes #29045.
* | | | | | | Fix RDoc formatting: `+` doesn't work with `@`ohbarye2017-08-112-6/+6
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* | | | | | Merge pull request #30142 from ↵Sean Griffin2017-08-081-4/+12
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | yukideluxe/add-missing-bit-reload-associations-docs add missing collection.reload documentation [ci skip]
| * | | | | | add missing collection.reload documentation [ci skip]Julia López2017-08-081-4/+12
| | | | | | |
* | | | | | | Document `ActiveRecord::AttributeMethods::Dirty`Sean Griffin2017-08-081-9/+9
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | This module has behavior that is not present in `ActiveModel::Dirty`, which is intended to be public API.