Commit Graph

36 Commits

Author SHA1 Message Date
Yves Senn
bec9e83359 tests, favor public API over inspecting columns where possible.
This is a follow up to 07786c5e75
and cd2596f55e
2014-12-01 16:57:48 +01:00
Yves Senn
07786c5e75 tests, run numeric default tests for every adapter. 2014-12-01 16:26:40 +01:00
Yves Senn
cd2596f55e tests, use public API to verify default parsing. #17863, #17856 2014-12-01 16:07:57 +01:00
Guo Xiang Tan
0270363f5c Fix value extracted from negative integers for PostgreSQL.
Fixes: https://github.com/rails/rails/issues/17856.
2014-12-01 22:00:04 +08:00
Sean Griffin
4d3e88fc75 Don't type cast the default on the column
If we want to have type decorators mess with the attribute, but not the
column, we need to stop type casting on the column. Where possible, we
changed the tests to test the value of `column_defaults`, which is
public API. `Column#default` is not.
2014-06-17 16:02:53 -06:00
Sean Griffin
405fd22e70 Collapse PG default extractoin of most types to single regex
For any type that is represented as a string and then type cast, we do
not need separate regular expressions for the various types. No function
will match this regex. User defined types *should* match this, so that
the type object can decide what to do with the value.
2014-06-04 07:44:06 -06:00
Sean Griffin
8df8334327 Remove dead test code for unsupported adapters 2014-05-17 13:24:25 -06:00
Guo Xiang Tan
3baace687c Use teardown helper method.
Follow-Up to https://github.com/rails/rails/pull/14348

Ensure that SQLCounter.clear_log is called after each test.

This is a step to prevent side effects when running tests. This will allow us to run them in random order.
2014-03-14 20:48:59 -07:00
Dylan Markow
78f6268977 Handle single quotes in PostgreSQL default column values
PostgreSQL escapes single quotes by using an additional single quote.
When Rails queries the column information, PostgreSQL returns the
default values with the escaped single quotes.

#extract_value_from_default now converts these to one single quote each.

Fixes #10881.
2013-06-19 11:03:40 -05:00
Rafael Mendonça França
bb38df89bf Standardize the use of current_adapter? 2013-01-01 19:18:34 -03:00
Jon Leighton
9e4c41c903 Remove ActiveRecord::Model
In the end I think the pain of implementing this seamlessly was not
worth the gain provided.

The intention was that it would allow plain ruby objects that might not
live in your main application to be subclassed and have persistence
mixed in. But I've decided that the benefit of doing that is not worth
the amount of complexity that the implementation introduced.
2012-10-26 15:51:02 +01:00
Jon Leighton
af8c8b432a The default value of a text/blob in mysql strict mode should be nil
In non-strict mode it is '', but if someone is in strict mode then we
should honour the strict semantics.

Also, this removes the need for a completely horrible hack in dirty.rb.

Closes #7780
2012-10-19 15:08:58 +01:00
Arturo Pie
2da85edda3 #7914 get default value when type uses schema name
PostgreSQL adapter properly parses default values when using multiple
schemas and domains.

When using domains across schemas, PostgresSQL prefixes the type of the
default value with the name of the schema where that type (or domain) is.

For example, this query:
```
SELECT a.attname, d.adsrc
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = "defaults"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum;
```

could return something like "'<default_value>'::pg_catalog.text" or
"(''<default_value>'::pg_catalog.text)::text" for the text columns with
defaults.

I modified the regexp used to parse this value so that it ignores
anything between ':: and \b(?:character varying|bpchar|text), and it
allows to have optional parens like in the above second example.
2012-10-13 19:41:50 -04:00
Xavier Noria
447b6a4e67 removes usage of Object#in? from the code base (the method remains defined by Active Support)
Selecting which key extensions to include in active_support/rails
made apparent the systematic usage of Object#in? in the code base.
After some discussion in

    5ea6b0df9a

we decided to remove it and use plain Ruby, which seems enough
for this particular idiom.

In this commit the refactor has been made case by case. Sometimes
include? is the natural alternative, others a simple || is the
way you actually spell the condition in your head, others a case
statement seems more appropriate. I have chosen the one I liked
the most in each case.
2012-08-06 00:30:02 +02:00
Xavier Noria
5ea6b0df9a load active_support/core_ext/object/inclusion in active_support/rails 2012-08-02 21:59:22 +02:00
Aaron Patterson
61774e0d49 please use ruby -I lib:test path/to/test.rb, or export RUBY_OPT 2011-06-06 15:47:13 -07:00
Jon Leighton
253bb6b926 Refactor Active Record test connection setup. Please see the 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. 2011-06-04 23:47:03 +01:00
Prem Sichanugrist
733bfa63f5 Remove #among? from Active Support
After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now.

It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`.
2011-04-13 20:25:28 +08:00
David Heinemeier Hansson
d1575ae1b9 Change Object#either? to Object#among? -- thanks to @jamesarosen for the suggestion! 2011-04-12 00:23:07 +02:00
Prem Sichanugrist
a9f3c9da01 Using Object#in? and Object#either? in various places
There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
2011-04-11 03:17:09 +08:00
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
Brian Lopez
21e81da335 update tests for mysql2 support 2010-08-02 01:37:57 -07:00
Xavier Noria
f17159b029 edit pass: the names of Rails components have a space, ie, "Active Record", not "ActiveRecord" 2010-06-14 23:22:04 +02:00
Neeraj Singh
b462952886 Use better assertion methods for testing
[#4645 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-19 10:18:36 +02:00
Aaron Patterson
1def14309f cleaning up a bunch of parse time warnings in AR [#4186 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
2010-03-15 18:22:31 -07:00
Hongli Lai (Phusion)
ccb96f2297 Merge commit 'origin/master' into savepoints
Conflicts:
	activerecord/lib/active_record/fixtures.rb
	activerecord/test/cases/defaults_test.rb
2008-12-03 19:30:35 +01:00
Ken Collins
8e4624be9e Remove SQL Server cases from tests for latest adapter work to pass rails expected behavior.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-11-19 18:00:56 +01:00
Hongli Lai (Phusion)
f48703e8c6 Fix the final MySQL unit test failure that's related to savepoint support. 2008-11-03 20:55:53 +01:00
Jonathan Viney
b1b204abbb Fix what looks like a Mysql bug with transactions, savepoints, and create table. 2008-11-03 20:55:33 +01:00
Frederick Cheung
d51a39ff50 Deal with MySQL's quirky handling of defaults and blob/text columns
[#1043 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2008-09-14 17:11:22 -07:00
Tarmo Tänav
fa795ccfad Include mysql older than 5.1.23 in the 5.1 series in the list of those that can't handle NULL defaults
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2008-08-26 00:53:19 -07:00
Ryan Bates
f7015336f6 Fix default nil tests for MySQL 5.0.51 [#192 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2008-05-31 12:36:07 -07:00
Jeremy Kemper
9a947af0e7 PostgreSQL: support server versions 7.4 through 8.0 and the ruby-pg driver. Closes #11127
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8922 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-02-22 03:26:21 +00:00
Jeremy Kemper
39814fcce0 Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8681 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-21 17:20:51 +00:00
Jeremy Kemper
1e70928014 Fix paths
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8661 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-18 07:31:37 +00:00
Jeremy Kemper
42b39ae3f2 Move tests to cases
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8660 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-18 07:30:42 +00:00