提交 2c845f6b 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #30976 from yahonda/supports_extensions_always_true

`supports_extensions?` return always true since PostgreSQL 9.1
......@@ -337,18 +337,12 @@ def disable_extension(name)
end
def extension_enabled?(name)
if supports_extensions?
res = exec_query("SELECT EXISTS(SELECT * FROM pg_available_extensions WHERE name = '#{name}' AND installed_version IS NOT NULL) as enabled", "SCHEMA")
res.cast_values.first
end
end
def extensions
if supports_extensions?
exec_query("SELECT extname FROM pg_extension", "SCHEMA").cast_values
else
super
end
end
# Returns the configured supported identifier length supported by PostgreSQL
......
......@@ -3,8 +3,7 @@
require "cases/helper"
require "support/schema_dumping_helper"
if ActiveRecord::Base.connection.supports_extensions?
class PostgresqlCitextTest < ActiveRecord::PostgreSQLTestCase
class PostgresqlCitextTest < ActiveRecord::PostgreSQLTestCase
include SchemaDumpingHelper
class Citext < ActiveRecord::Base
self.table_name = "citexts"
......@@ -76,5 +75,4 @@ def test_schema_dump_with_shorthand
output = dump_table_schema("citexts")
assert_match %r[t\.citext "cival"], output
end
end
end
......@@ -22,10 +22,6 @@ def setup
@connection = ActiveRecord::Base.connection
unless @connection.supports_extensions?
return skip("no extension support")
end
@old_schema_migration_table_name = ActiveRecord::SchemaMigration.table_name
@old_table_name_prefix = ActiveRecord::Base.table_name_prefix
@old_table_name_suffix = ActiveRecord::Base.table_name_suffix
......
......@@ -3,8 +3,7 @@
require "cases/helper"
require "support/schema_dumping_helper"
if ActiveRecord::Base.connection.supports_extensions?
class PostgresqlHstoreTest < ActiveRecord::PostgreSQLTestCase
class PostgresqlHstoreTest < ActiveRecord::PostgreSQLTestCase
include SchemaDumpingHelper
class Hstore < ActiveRecord::Base
self.table_name = "hstores"
......@@ -376,5 +375,4 @@ def assert_cycle(hash)
x.reload
assert_equal(hash, x.tags)
end
end
end
......@@ -222,7 +222,6 @@ class UUID < ActiveRecord::Base
connection.execute "DROP FUNCTION IF EXISTS my_uuid_generator();"
end
if ActiveRecord::Base.connection.supports_extensions?
def test_id_is_uuid
assert_equal :uuid, UUID.columns_hash["id"].type
assert UUID.primary_key
......@@ -284,7 +283,6 @@ def migrate(x)
drop_table "pg_uuids_4"
ActiveRecord::Migration.verbose = @verbose_was
end
end
end
class PostgresqlUUIDTestNilDefault < ActiveRecord::PostgreSQLTestCase
......@@ -302,7 +300,6 @@ class PostgresqlUUIDTestNilDefault < ActiveRecord::PostgreSQLTestCase
drop_table "pg_uuids"
end
if ActiveRecord::Base.connection.supports_extensions?
def test_id_allows_default_override_via_nil
col_desc = connection.execute("SELECT pg_get_expr(d.adbin, d.adrelid) as default
FROM pg_attribute a
......@@ -334,7 +331,6 @@ def migrate(x)
drop_table "pg_uuids_4"
ActiveRecord::Migration.verbose = @verbose_was
end
end
end
class PostgresqlUUIDTestInverseOf < ActiveRecord::PostgreSQLTestCase
......@@ -367,7 +363,6 @@ class UuidComment < ActiveRecord::Base
drop_table "pg_uuid_posts"
end
if ActiveRecord::Base.connection.supports_extensions?
def test_collection_association_with_uuid
post = UuidPost.create!
comment = post.uuid_comments.create!
......@@ -385,5 +380,4 @@ def test_find_by_with_uuid
UuidPost.create!
assert_nil UuidPost.find_by(id: 789)
end
end
end
......@@ -294,7 +294,6 @@ def test_schema_dump_oid_type
assert_match %r{t\.oid\s+"obj_id"$}, output
end
if ActiveRecord::Base.connection.supports_extensions?
def test_schema_dump_includes_extensions
connection = ActiveRecord::Base.connection
......@@ -323,7 +322,6 @@ def test_schema_dump_includes_extensions_in_alphabetic_order
assert_equal ["hstore", "uuid-ossp", "xml2"], enabled_extensions
end
end
end
def test_schema_dump_keeps_large_precision_integer_columns_as_decimal
output = standard_dump
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册