aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Tiny documentation edits [ci skip]Robin Dupret2015-02-241-1/+1
|
* Fix mysql's schema.rb dumper so it does not include limit on emulated ↵Court3nay2015-02-241-0/+1
| | | | boolean tinyint(1) fields
* rework `disable_referential_integrity` for PostgreSQL.Yves Senn2015-02-241-9/+28
| | | | | | | | | | | | | | | | | | | | | | | [Toby Ovod-Everett & Andrey Nering & Yves Senn] Closes #17726. Closes #10939. This patch makes three distinct modifications: 1. no longer fall back to disabling user triggers if system triggers can't be disabled 2. warn the user when referential integrity can't be disabled 3. restore aborted transactions when referential integrity can't be disabled The motivation behind these changes is to make the behavior of Rails transparent and less error-prone. To require superuser privileges is not optimal but it's what Rails currently needs. Users who absolutely rely on disabling user triggers can patch `disable_referential_integrity`. We should investigate `SET CONSTRAINTS` as a possible solution which does not require superuser privileges. /cc @matthewd
* Move back `new_column_definition` into `TableDefinition`Ryuta Kamizono2015-02-251-4/+4
| | | | | | | | | Only `primary_key` should be extracted by d47357e in #19030, but `new_coclumn_definition` was also extracted because #17631 is merged previously, then #19030 is auto merged without conflicts. This commit is for move back `new_column_definition` into `TableDefinition`.
* Merge pull request #19030 from kamipo/extract_short_hand_column_methodsRafael Mendonça França2015-02-233-109/+139
|\ | | | | Extract the short-hand column methods into `ColumnMethods`
| * The short-hand methods should be able to define multiple columnsRyuta Kamizono2015-02-231-44/+50
| |
| * Extract the short-hand methods into `ColumnMethods`Ryuta Kamizono2015-02-231-23/+28
| |
| * Extract `primary_key` method into `ColumnMethods`Ryuta Kamizono2015-02-223-42/+61
| |
* | Allow `:limit` option for MySQL bigint primary key supportRyuta Kamizono2015-02-241-0/+10
|/ | | | | | | | | | | | | Example: create_table :foos, id: :primary_key, limit: 8 do |t| end # or create_table :foos, id: false do |t| t.column :id, limit: 8 end
* Format the time string according to the precision of the time columnRyuta Kamizono2015-02-201-2/+2
| | | | It is also necessary to format a time column like a datetime column.
* Allow `:precision` option for time type columnsRyuta Kamizono2015-02-205-13/+19
|
* Merge pull request #18916 from kamipo/handle_array_option_in_type_to_sqlRafael Mendonça França2015-02-192-37/+25
|\ | | | | Handle array option in `type_to_sql`
| * Handle array option in `type_to_sql`Ryuta Kamizono2015-02-191-19/+16
| | | | | | | | | | `[]` is a part of `sql_type`, so it is always necessary to respect to array option when `type_to_sql` is called.
| * Use `delegate` to call the methods to `@conn`Ryuta Kamizono2015-02-191-16/+3
| |
| * Should handle array option for `:cast_as`Ryuta Kamizono2015-02-191-4/+8
| |
* | Extract precision from datetime and time columnsRyuta Kamizono2015-02-192-7/+4
|/ | | | | | | | The cause by which the test suite for the mysql adapter broke in 1502cae (reverted 89ba5bb) is because the precision was not extracted. The rounding problem in mysql adapter has not been fixed, but `mysql_56` helper tested only mysql2 adapter, its behavior was not apparent.
* Rm `Type#type_cast`Sean Griffin2015-02-176-8/+8
| | | | | | | | | This helper no longer makes sense as a separate method. Instead I'll just have `deserialize` call `cast` by default. This led to a random infinite loop in the `JSON` pg type, when it called `super` from `deserialize`. Not really a great way to fix that other than not calling super, or continuing to have the separate method, which makes the public API differ from what we say it is.
* `type_cast_from_user` -> `cast`Sean Griffin2015-02-171-2/+2
|
* `type_cast_for_database` -> `serialize`Sean Griffin2015-02-1712-15/+15
|
* `Type#type_cast_from_database` -> `Type#deserialize`Sean Griffin2015-02-178-9/+9
|
* Revert "Allow `:precision` option for time type columns"Sean Griffin2015-02-175-21/+19
| | | | | | | | | | 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
* Merge pull request #18662 from estum/foreign-key-existsYves Senn2015-02-162-15/+38
|\ | | | | | | Add `foreign_key_exists?` method.
| * Add methods to get foreign key matching argumentsAnton2015-01-292-40/+36
| |
| * Add `foreign_key_exists?` method.Anton2015-01-242-0/+27
| |
* | fix, `to_table` in `remove_foreign_key` should be plural.Yves Senn2015-02-161-1/+1
| |
* | Register adapter specific types with the global type registrySean Griffin2015-02-154-62/+21
| | | | | | | | | | | | We do this in the adapter classes specifically, so the types aren't registered if we don't use that adapter. Constants under the PostgreSQL namespace for example are never loaded if we're using mysql.
* | Allow `:precision` option for time type columnsRyuta Kamizono2015-02-125-19/+21
| |
* | Merge pull request #18888 from kamipo/refactor_quote_default_expressionRafael Mendonça França2015-02-114-18/+12
|\ \ | | | | | | Refactor `quote_default_expression`
| * | Refactor `quote_default_expression`Ryuta Kamizono2015-02-114-18/+12
| | | | | | | | | | | | | | | | | | | | | `quote_default_expression` and `quote_default_value` are almost the same handling for do not quote default function of `:uuid` columns. Rename `quote_default_value` to `quote_default_expression`, and remove duplicate code.
* | | Remove the SQLite3 Binary subclassSean Griffin2015-02-111-18/+0
| | | | | | | | | | | | | | | | | | As far as I can tell, the original reason that this behavior was added has been sufficiently resolved elsewhere, as we no longer remove the encoding of strings coming out of the database.
* | | Remove an unused option that I didn't mean to commit [ci skip]Sean Griffin2015-02-111-2/+1
| | |
* | | Remove most PG specific type subclassesSean Griffin2015-02-1112-89/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | The latest version of the PG gem can actually convert the primitives for us in C code, which gives a pretty substantial speed up. A few cases were only there to add the `infinity` method, which I just put on the range type (which is the only place it was used). Floats also needed to parse `Infinity` and `NaN`, but it felt reasonable enough to put that on the generic form.
* | | Merge pull request #18883 from ↵Sean Griffin2015-02-112-1/+7
|\ \ \ | | | | | | | | | | | | | | | | kamipo/fix_datetime_precision_dumping_zero_for_postgresql The datetime precision with zero should be dumped
| * | | The datetime precision with zero should be dumpedRyuta Kamizono2015-02-112-1/+7
| |/ / | | | | | | | | | | | | `precision: 0` was not dumped by f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7. However, `precision: 0` is valid value for PostgreSQL timestamps.
* | | fix `remove_reference` with `foreign_key: true` on MySQL. #18664.Yves Senn2015-02-111-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL rejects to remove an index which is used in a foreign key constraint: ``` ActiveRecord::StatementInvalid: Mysql2::Error: Cannot drop index 'index_copies_on_title_id': needed in a foreign key constraint: ALTER TABLE `copies` DROP `title_id` ``` Removing the constraint before removing the column (and the index) solves this problem.
* | | Merge pull request #18890 from kamipo/remove_cast_typeYves Senn2015-02-111-1/+1
|\ \ \ | | | | | | | | Remove `cast_type` in `ColumnDefinition`
| * | | Remove `cast_type` in `ColumnDefinition`Ryuta Kamizono2015-02-111-1/+1
| |/ / | | | | | | | | | This is no longer needed.
* / / Use keyword argument in `transaction`Ryuta Kamizono2015-02-111-6/+4
|/ / | | | | | | | | The keys are already validated, so it is better to use the built-in feature to do this.
* | Refactor microsecond precision to be database agnosticSean Griffin2015-02-105-46/+32
| | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #18849 from kamipo/array_type_is_a_part_of_sql_typeSean Griffin2015-02-092-19/+4
|\ \ | | | | | | An array type is a part of `sql_type`
| * | An array type is a part of `sql_type`Ryuta Kamizono2015-02-082-19/+4
| | | | | | | | | | | | | | | | | | `sql_type` is reused in `lookup_cast_type`. If making it a part of `sql_type` when handled array option first, it isn't necessary to do again.
* | | Fix rounding problem for PostgreSQL timestamp columnRyuta Kamizono2015-02-082-12/+13
| | | | | | | | | | | | | | | If timestamp column have the precision, it need to format according to the precision of timestamp column.
* | | Merge pull request #18602 from kamipo/respect_database_charset_and_collationAndrew White2015-02-081-1/+1
|\ \ \ | | | | | | | | Respect the database default charset for `schema_migrations` table.
| * | | Respect the database default charset for `schema_migrations` table.Ryuta Kamizono2015-02-081-1/+1
| |/ / | | | | | | | | | | | | | | | The charset of `version` column in `schema_migrations` table is depend on the database default charset and collation rather than the encoding of the connection.
* / / Add `auto_increment?` instead of `extra == 'auto_increment'`Ryuta Kamizono2015-02-081-2/+6
|/ /
* | rm `Type#text?`Sean Griffin2015-02-073-5/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Move non-type objects into the `Type::Helpers` namespaceSean Griffin2015-02-074-4/+4
| | | | | | | | | | | | | | The type code is actually quite accessible, and I'm planning to encourage people to look at the files in the `type` folder to learn more about how it works. This will help reduce the noise from code that is less about type casting, and more about random AR nonsense.
* | Allow a symbol to be passed to `attribute`, in place of a type objectSean Griffin2015-02-066-1/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The same is not true of `define_attribute`, which is meant to be the low level no-magic API that sits underneath. The differences between the two APIs are: - `attribute` - Lazy (the attribute will be defined after the schema has loaded) - Allows either a type object or a symbol - `define_attribute` - Runs immediately (might get trampled by schema loading) - Requires a type object This was the last blocker in terms of public interface requirements originally discussed for this feature back in May. All the implementation blockers have been cleared, so this feature is probably ready for release (pending one more look-over by me).
* | fix transaction rollback in case of aborting threadYuri Smirnov2015-02-051-1/+1
| |
* | Add default options to 'bit' and 'bit_varying' methodsMelody2015-02-031-2/+2
| |