aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
Commit message (Collapse)AuthorAgeFilesLines
* Dump indexes in `create_table` for generates SQL in one queryRyuta Kamizono2016-04-201-20/+33
| | | | | If the adapter supports indexes in create table, it generates SQL in one query.
* Fix `test_blank_columns_created_in_block`Ryuta Kamizono2016-04-201-1/+1
| | | | Follow up to 1683410.
* Database comments: Treat blank comments as no comment. Don't dump blank ↵Jeremy Daer2016-04-192-2/+2
| | | | comments.
* Define `arel_visitor` method on all adaptersRyuta Kamizono2016-04-204-1/+13
| | | | `Arel::Visitors::VISITORS` was removed at https://github.com/rails/arel/pull/412.
* Merge pull request #24317 from Gaurav2728/unused_set_in_active_recordJeremy Daer2016-04-192-3/+0
|\ | | | | | | connection adapters column, delegation in Active Record have not use …
| * connection adapters column, delegation in Active Record have not use of ↵Gaurav Sharma2016-03-312-3/+0
| | | | | | | | | | ‘set’ found these commits https://github.com/rails/rails/commit/9cc8c6f3730df3d94c81a55be9ee1b7b4ffd29f6, https://github.com/rails/rails/commit/9d79334a1dee67e31222c790e231772deafcaeb8 that also should remove it.
* | Merge pull request #24576 from yahonda/quote_column_name_for_reserved_word_sizeJeremy Daer2016-04-191-1/+1
|\ \ | | | | | | | | | Address ORA-00923 error by quoting a reserved word "SIZE"
| * | Address ORA-00923 error by quoting a reserved word "SIZE"Yasuo Honda2016-04-161-1/+1
| | |
* | | Merge pull request #23497 from kamipo/extract_schema_qualified_nameJeremy Daer2016-04-191-8/+15
|\ \ \ | | | | | | | | | | | | Extract `extract_schema_qualified_name` method
| * | | Extract `extract_schema_qualified_name` methodRyuta Kamizono2016-02-051-8/+15
| | | |
* | | | Merge pull request #23515 from kamipo/extract_arel_visitorJeremy Daer2016-04-194-28/+12
|\ \ \ \ | | | | | | | | | | | | | | | Extract `arel_visitor` and move up to the abstract adapter
| * | | | Extract `arel_visitor` and move up to the abstract adapterRyuta Kamizono2016-04-044-28/+12
| | | | |
* | | | | Merge pull request #23523 from kamipo/avoid_truncation_in_uniqueness_validationJeremy Daer2016-04-181-3/+0
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Avoid a string value truncation in uniqueness validation
| * | | | | Avoid a string value truncation in uniqueness validationRyuta Kamizono2016-02-121-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In MySQL, PostgreSQL, Oracle and SQLServer, a value over the limit cannot be inserted or updated (See #23522). In SQLite3, a value is inserted or updated regardless of the limit. We should avoid a string value truncation in uniqueness validation.
* | | | | | Merge pull request #23522 from kamipo/add_value_too_long_exception_classJeremy Daer2016-04-183-0/+9
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | Add `ActiveRecord::ValueTooLong` exception class
| * | | | | | Add `ActiveRecord::ValueTooLong` exception classRyuta Kamizono2016-02-063-0/+9
| | | | | | |
* | | | | | | `foreign_key` respects `table_name_prefix` and `table_name_suffix`Ryuta Kamizono2016-04-191-0/+3
| | | | | | |
* | | | | | | Merge pull request #23622 from kamipo/primary_key_should_be_not_nullJeremy Daer2016-04-184-3/+10
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Primary key should be `NOT NULL`
| * | | | | | | Primary key should be `NOT NULL`Ryuta Kamizono2016-03-124-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up to #18228. In MySQL and PostgreSQL, primary key is to be `NOT NULL` implicitly. But in SQLite it must be specified `NOT NULL` explicitly.
* | | | | | | | Merge pull request #24607 from vipulnsward/where-clause-frozen-arraySean Griffin2016-04-181-1/+2
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Don't create new arrays when trying to compute non_empty_predicates for ast generation
| * | | | | | | | Don't create new arrays when trying to compute non_empty_predicates for ↵Vipul A M2016-04-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | where clause predicate. Get a 3-4% improvement in AST generation. Perf compare: https://gist.github.com/vipulnsward/7e4e9ecb157e574002313249a7969c82
* | | | | | | | | Database comments: switch to keyword args for new table optionsJeremy Daer2016-04-1810-66/+78
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Switch to keyword args where we can without breaking compat. * Use add_table_options! for :options, too. * Some code polish.
* | | | | | | | Merge pull request #24535 from tomash/association-validate-docsVipul A M2016-04-181-4/+8
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Update ActiveRecord associations documentation on :validate option [ci skip]
| * | | | | | | | [ci skip] Update ActiveRecord associations documentation to avoid confusion ↵Tomasz Stachewicz2016-04-181-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with :validate option. Caused by #24532.
* | | | | | | | | Merge pull request #24551 from bogdanvlviv/notice_for_tasksJeremy Daer2016-04-171-2/+4
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | Added notice when a database is successfully created or dropped.
| * | | | | | | | | Added notice when a database is successfully created or dropped.bogdanvlviv2016-04-171-2/+4
| | | | | | | | | |
* | | | | | | | | | Merge pull request #22911 from Envek/database_commentsJeremy Daer2016-04-1612-37/+170
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for specifying comments for tables, columns, and indexes in database itself
| * | | | | | | | | | Add support for specifying comments for tables, columns, and indexes.Andrey Novikov2016-04-1612-37/+170
| | |_|_|_|_|_|_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Comments are specified in migrations, stored in database itself (in its schema), and dumped into db/schema.rb file. This allows to generate good documentation and explain columns and tables' purpose to everyone from new developers to database administrators. For PostgreSQL and MySQL only. SQLite does not support comments at the moment. See docs for PostgreSQL: http://www.postgresql.org/docs/current/static/sql-comment.html See docs for MySQL: http://dev.mysql.com/doc/refman/5.7/en/create-table.html
* | | | | | | | | | documentation for add_references index option [ci skip]Vipul A M2016-04-171-1/+10
|\ \ \ \ \ \ \ \ \ \ | |/ / / / / / / / / |/| | | | | | | | | documentation for add_references index option [ci skip]
| * | | | | | | | | [ci skip] docs for add_references index optionAlex Handley2016-04-161-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add link for finding the addional options for index. - Add example for unique index as this is a common requirement. - Add link in guide for index options.
* | | | | | | | | | Should keep quoting behaivor of a time column value in sqlite3 adapterRyuta Kamizono2016-04-151-0/+4
| |/ / / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up to #24542. In MySQL and PostgreSQL, a time column value is saved as ignored the date part of it. But in SQLite3, a time column value is saved as a string. We should keep previous quoting behavior in sqlite3 adapter. ``` sqlite> CREATE TABLE "foos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "start" time(0), "finish" time(4)); sqlite> INSERT INTO "foos" ("start", "finish") VALUES ('2000-01-01 12:30:00', '2000-01-01 12:30:00.999900'); sqlite> SELECT "foos".* FROM "foos"; 1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900 sqlite> SELECT "foos".* FROM "foos" WHERE "foos"."start" = '2000-01-01 12:30:00' LIMIT 1; 1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900 sqlite> SELECT "foos".* FROM "foos" WHERE "foos"."start" = '12:30:00' LIMIT 1; sqlite> ```
* | | | | | | | | Add `quoted_time` for truncating the date part of a time column valueRyuta Kamizono2016-04-142-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Context #24522. TIME column on MariaDB doesn't ignore the date part of the string when it coerces to time. ``` root@localhost [test] > CREATE TABLE `foos` (`id` int AUTO_INCREMENT PRIMARY KEY, `start` time(0), `finish` time(4)) ENGINE=InnoDB; Query OK, 0 rows affected (0.02 sec) root@localhost [test] > INSERT INTO `foos` (`start`, `finish`) VALUES ('2000-01-01 12:30:00', '2000-01-01 12:30:00.999900'); Query OK, 1 row affected, 2 warnings (0.00 sec) Note (Code 1265): Data truncated for column 'start' at row 1 Note (Code 1265): Data truncated for column 'finish' at row 1 root@localhost [test] > SELECT `foos`.* FROM `foos`; +----+----------+---------------+ | id | start | finish | +----+----------+---------------+ | 1 | 12:30:00 | 12:30:00.9999 | +----+----------+---------------+ 1 row in set (0.00 sec) root@localhost [test] > SELECT `foos`.* FROM `foos` WHERE `foos`.`start` = '2000-01-01 12:30:00' LIMIT 1; Empty set (0.00 sec) root@localhost [test] > SELECT `foos`.* FROM `foos` WHERE `foos`.`start` = '12:30:00' LIMIT 1; +----+----------+---------------+ | id | start | finish | +----+----------+---------------+ | 1 | 12:30:00 | 12:30:00.9999 | +----+----------+---------------+ 1 row in set (0.00 sec) ```
* | | | | | | | | Merge pull request #24522 from vipulnsward/run-mariadb-on-travisJeremy Daer2016-04-131-4/+4
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | Test against MariaDB 10.0
| * | | | | | | | | Include running mariadb on travisVipul A M2016-04-141-4/+4
| | |/ / / / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Specify we want to run on latest stable ruby for mariadb - change in runs of builds Make mariadb? method publicly available
* | | | | | | | | Merge pull request #24533 from vipulnsward/nodoc-versionSean Griffin2016-04-131-1/+1
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | :nodoc: version method.
| * | | | | | | | | :nodoc: version method.Vipul A M2016-04-131-1/+1
| |/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reason: - Its not publicly used method. - Exposing it makes an assumption that other adapters support it based on its usage - ActiveRecord::Base.connection.version [ci skip]
* | | | | | | | | Properly serialize all JSON primitives in the AR JSON typeSean Griffin2016-04-131-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we were assuming that the only valid types for encoding were arrays and hashes. However, any JSON primitive is an accepted value by both PG and MySQL. This does involve a minor breaking change in the handling of `default` in the schema dumper. This is easily worked around, as passing a hash/array literal would have worked fine in previous versions of Rails. However, because of this, I will not be backporting this to 4.2 or earlier. Fixes #24234
* | | | | | | | | Allow symbols using "dot notation" to be passed to whereSean Griffin2016-04-123-6/+6
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 04ac5655be91f49cd4dfe2838df96213502fb274 I assumed that we would never want to pass the "table_name.column_name" form to where with a symbol. However, in Ruby 2.2 and later, you can quote symbols using the new hash syntax, so it's a semi-reasonable thing to do if we want to support the dot notation (which I'd rather deprecate, but that would be too painful of a migration). Instead we've changed the definition of "this is a table name with a dot" to when the value associated is a hash. It would make very little sense to write `where("table_name.column_name": { foo: :bar })` in any scenario (other than equality for a JSON column which we don't support through `where` in this way). Close #24514.
* | | | | | | | Merge pull request #24492 from vipulnsward/pass-over-warningsJeremy Daer2016-04-116-10/+10
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | Clean up all Rails 5 warnings. Revert auto-added periods.
| * | | | | | | Pass over all Rails 5 warnings, to make sure:Vipul A M2016-04-126-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - we are ending sentences properly - fixing of space issues - fixed continuity issues in some sentences. Reverts https://github.com/rails/rails/commit/8fc97d198ef31c1d7a4b9b849b96fc08a667fb02 . This change reverts making sure we add '.' at end of deprecation sentences. This is to keep sentences within Rails itself consistent and with a '.' at the end.
* | | | | | | | Merge pull request #24485 from ↵Richard Schneeman2016-04-111-2/+2
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | prathamesh-sonpatki/protected_database_env_message Cleanup message shown while running destructive action against protected database
| * | | | | | | | Cleanup message shown while running destructive action against protected ↵Prathamesh Sonpatki2016-04-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | database.
* | | | | | | | | issue FileUtils commands directly in Rake tasksXavier Noria2016-04-111-1/+1
| |/ / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rake includes (an extended version of) FileUtils in tasks. It is more idiomatic that they use this provided interface.
* | | | | | | | Check for protected environments before trying to load structure.sql filePrathamesh Sonpatki2016-04-101-1/+1
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Check for protected environments while running `db:structure:load` similar to how `db:schema:load` behaves. - Followup of https://github.com/rails/rails/pull/24399.
* | | | | | | Support microsecond datetime precision on MariaDB 5.3+.Jeremy Daer2016-04-081-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We support microsecond datetime precision for MySQL 5.6.4+. MariaDB has supported it since 5.3.0, but even 10.x versions return a compatible version string like `5.5.5-10.1.8-MariaDB-log` which we parse as 5.5.5, before MySQL supported microsecond precision. Specialize our version check to account for MariaDB to fix.
* | | | | | | Merge pull request #24422 from matthewd/extinguish-executor-exceptionsMatthew Draper2016-04-071-14/+18
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Clean up after a failure in a run callback
| * | | | | | | Directly support stateful executor hooksMatthew Draper2016-04-051-14/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, make sure to call the +complete+ hooks if +run+ fails.
* | | | | | | | Merge pull request #24399 from jch/protect-against-db-schema-load-in-productionRichard Schneeman2016-04-061-1/+1
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Prevent db:schema:load to protected environments
| * | | | | | | | Prevent db:schema:load to protected environmentsJerry Cheung2016-04-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up to https://github.com/rails/rails/pull/22967 to protect against loading a schema on accident in production. cc @schneems
* | | | | | | | | Merge pull request #24078 from kamipo/show_variablesRafael França2016-04-061-2/+1
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | Simply use `select_value` in `show_variable`