aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorYasuo Honda <yasuo.honda@gmail.com>2017-04-26 04:45:08 +0000
committerYasuo Honda <yasuo.honda@gmail.com>2017-04-26 14:29:22 +0000
commit4181b677e5164a18fe25767c5bf9eeb3df800231 (patch)
tree9788a666aa2457ccc9ed62e68e1e9e0290bae9d3 /activerecord/test/cases
parentdeba47799ff905f778e0c98a015789a1327d5087 (diff)
downloadrails-4181b677e5164a18fe25767c5bf9eeb3df800231.tar.gz
rails-4181b677e5164a18fe25767c5bf9eeb3df800231.tar.bz2
rails-4181b677e5164a18fe25767c5bf9eeb3df800231.zip
PostgreSQL 10 allows `CURRENT_DATE` and `CURRENT_TIMESTAMP` as default functions
Address #28797 In the previous versions of PostgreSQL, `CURRENT_DATE` converted to `('now'::text)::date` and `CURRENT_TIMESTAMP` converted to `now()`. Refer these discussions and commit at PostgreSQL : https://www.postgresql.org/message-id/flat/5878.1463098164%40sss.pgh.pa.us#5878.1463098164@sss.pgh.pa.us https://github.com/postgres/postgres/commit/0bb51aa96783e8a6c473c2b5e3725e23e95db834
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/defaults_test.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/test/cases/defaults_test.rb b/activerecord/test/cases/defaults_test.rb
index a6297673c9..996d298689 100644
--- a/activerecord/test/cases/defaults_test.rb
+++ b/activerecord/test/cases/defaults_test.rb
@@ -87,9 +87,14 @@ if current_adapter?(:PostgreSQLAdapter)
test "schema dump includes default expression" do
output = dump_table_schema("defaults")
- assert_match %r/t\.date\s+"modified_date",\s+default: -> { "\('now'::text\)::date" }/, output
+ if ActiveRecord::Base.connection.postgresql_version >= 100000
+ assert_match %r/t\.date\s+"modified_date",\s+default: -> { "CURRENT_DATE" }/, output
+ assert_match %r/t\.datetime\s+"modified_time",\s+default: -> { "CURRENT_TIMESTAMP" }/, output
+ else
+ assert_match %r/t\.date\s+"modified_date",\s+default: -> { "\('now'::text\)::date" }/, output
+ assert_match %r/t\.datetime\s+"modified_time",\s+default: -> { "now\(\)" }/, output
+ end
assert_match %r/t\.date\s+"modified_date_function",\s+default: -> { "now\(\)" }/, output
- assert_match %r/t\.datetime\s+"modified_time",\s+default: -> { "now\(\)" }/, output
assert_match %r/t\.datetime\s+"modified_time_function",\s+default: -> { "now\(\)" }/, output
end
end