aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/column_definition_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Make internal methods to privateRyuta Kamizono2017-03-271-1/+1
|
* Refactor `ColumnDefinition` to contain `options` hashRyuta Kamizono2017-02-091-13/+3
| | | | | | Column options are passed as an hash args then used as `options` hash in `add_column_options!`. Converting args to attributes is inconvinient for using options as an hash.
* Remove useless `MySQL::Column` testsRyuta Kamizono2017-02-071-42/+0
| | | | | | | Since text default treated as an empty string in non-strict mode has been removed in #26154, `MySQL::Column` behaves like any other column. Also, The difference between strict and non-strict mode is covered by `test_mysql_not_null_defaults_strict` and `test_mysql_not_null_defaults_non_strict`.
* Remove text default treated as an empty string in non-strict modeRyuta Kamizono2016-08-191-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. If strict mode is not in effect, MySQL inserts adjusted values for invalid or missing values and produces warnings. ```ruby def test_mysql_not_null_defaults_non_strict using_strict(false) do with_mysql_not_null_table do |klass| record = klass.new assert_nil record.non_null_integer assert_nil record.non_null_string assert_nil record.non_null_text assert_nil record.non_null_blob record.save! record.reload assert_equal 0, record.non_null_integer assert_equal "", record.non_null_string assert_equal "", record.non_null_text assert_equal "", record.non_null_blob end end end ``` It is inconsistent with other types that only text/blob defaults treated as an empty string. This commit fixes the inconsistency.
* Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-061-2/+2
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-3/+3
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-1/+1
|
* Remove unnecessary `assert_valid_default`Ryuta Kamizono2016-06-251-7/+0
| | | | | This was added at c7c3f73 but it never raised because MySQL cannot create text/blob columns with a default value.
* Extract `MySQL::TypeMetadata` class to ↵Ryuta Kamizono2016-01-111-1/+1
| | | | `connection_adapters/mysql/type_metadata.rb`
* Extract `MySQL::Column` class to `connection_adapters/mysql/column.rb`Ryuta Kamizono2016-01-111-10/+10
|
* Fix varbinary with default ''Ryuta Kamizono2015-12-241-0/+10
| | | | | | | A `(?:var)?binary` with default '' is a correct definition. Remove `missing_default_forged_as_empty_string?` method for fixing this issue because this method is a workaround for older mysql legacy adapter (19c99ac, f7015336).
* Remove legacy mysql adapterAbdelkader Boudih2015-12-171-1/+1
|
* rm `Column#cast_type`Sean Griffin2015-02-031-60/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The type from the column is never used, except when being passed to the attributes API. While leaving the type on the column wasn't necessarily a bad thing, I worry that it's existence there implies that it is something which should be used. During the design and implementation process of the attributes API, there have been plenty of cases where getting the "right" type object was hard, but I had easy access to the column objects. For any contributor who isn't intimately familiar with the intents behind the type casting system, grabbing the type from the column might easily seem like the "correct" thing to do. As such, the goal of this change is to express that the column is not something that should be used for type casting. The only places that are "valid" (at the time of this commit) uses of acquiring a type object from the column are fixtures (as the YAML file is going to mirror the database more closely than the AR object), and looking up the type during schema detection to pass to the attributes API Many of the failing tests were removed, as they've been made obsolete over the last year. All of the PG column tests were testing nothing beyond polymorphism. The Mysql2 tests were duplicating the mysql tests, since they now share a column class. The implementation is a little hairy, and slightly verbose, but it felt preferable to going back to 20 constructor options for the columns. If you are git blaming to figure out wtf I was thinking with them, and have a better idea, go for it. Just don't use a type object for this.
* Remove unused `Column#coder`Sean Griffin2014-05-281-20/+0
| | | | | It appears this property was added, but never actually used. It would be broken if it were, as it only type casts one way.
* Push limit to type objectsSean Griffin2014-05-221-3/+3
| | | | | Columns and injected types no longer have any conditionals based on the format of SQL type strings! Hooray!
* Delegate `Column#type` to the injected type objectSean Griffin2014-05-191-22/+22
| | | | | | | | | | | | | | | | The decision to wrap type registrations in a proc was made for two reasons. 1. Some cases need to make an additional decision based on the type (e.g. a `Decimal` with a 0 scale) 2. Aliased types are automatically updated if they type they point to is updated later. If a user or another adapter decides to change the object used for `decimal` columns, `numeric`, and `number` will automatically point to the new type, without having to track what types are aliased explicitly. Everything else here should be pretty straightforward. PostgreSQL ranges had to change slightly, since the `simplified_type` method is gone.
* Add a type object to Column constructorSean Griffin2014-05-171-22/+22
| | | | | | Part of #15134. In order to perform typecasting polymorphically, we need to add another argument to the constructor. The order was chosen to match the `oid_type` on `PostgreSQLColumn`.
* PostgreSQL determine `Column#type` through corresponding OID. #7814Yves Senn2014-04-011-2/+2
| | | | | | | | | | | | | I ran the whole test suite and compared the old to the new types. Following is the list of types that did change with this patch: ``` DIFFERENT TYPE FOR mood: NEW: enum, BEFORE: DIFFERENT TYPE FOR floatrange: NEW: floatrange, BEFORE: float ``` The `floatrange` is a custom type. The old type `float` was simply a coincidence form the name `floatrange` and our type-guessing.
* Fixed typo in column_definition_test.rb.Vajrasky Kok2014-02-051-2/+2
|
* decouple column definition from the database connectionAaron Patterson2013-03-221-3/+3
|
* remove knowledge of SQL from the column definition objectAaron Patterson2013-03-221-3/+4
|
* Add uuid type support to PostgreSQL adapterKonstantin Shabanov2012-06-141-6/+0
|
* PG column consults oid types when typecastingAaron Patterson2012-02-101-3/+6
|
* Create an AbstractMysqlAdapter to abstract the common code between ↵Jon Leighton2011-08-291-16/+16
| | | | MysqlAdapter and Mysql2Adapter.
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* column will use coder to typecase value when it is availableAaron Patterson2011-02-011-0/+6
|
* coders can be assigned to columnsAaron Patterson2011-02-011-0/+14
|
* namespace test so we can dry up constant lookupAaron Patterson2011-02-011-95/+99
|
* update tests for mysql2 supportBrian Lopez2010-08-021-0/+34
|
* Use better assertion methods for testingNeeraj Singh2010-05-191-3/+3
| | | | | | [#4645 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Add tests for postgresql column type mapping updates [#4270 state:resolved]Ernie Miller2010-03-311-0/+17
| | | | Signed-off-by: Emilio Tagua <miloops@gmail.com>
* AR should respect default values for MySQL BINARY and VARBINARY columns.Jatinder Singh2009-08-091-0/+34
| | | | | | [#1273 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Don't set "NULL" as a constraint on nullable columns [#398 state:resolved]Tarmo Tänav2008-08-231-4/+4
| | | | This is already the default and adding it breaks SQL standards compatibility.
* Fixed that create database statements would always include "DEFAULT NULL" ↵David Heinemeier Hansson2008-07-141-0/+36
(Nick Sieger) [#334 status:committed]