Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valid_type? should accept only supported types #28220

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ def supports_index_sort_order?
true
end

def valid_type?(type) # :nodoc:
true
end

# Returns 62. SQLite supports index names up to 64
# characters. The rest is used by Rails internally to perform
# temporary rename operations
Expand Down
10 changes: 10 additions & 0 deletions activerecord/test/cases/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ def test_create_record_with_pk_as_zero
assert_nothing_raised { Book.destroy(0) }
end

def test_valid_column
@connection.native_database_types.each_key do |type|
assert @connection.valid_type?(type)
end
end

def test_invalid_column
assert_not @connection.valid_type?(:foobar)
end

def test_tables
tables = @connection.tables
assert_includes tables, "accounts"
Expand Down
11 changes: 0 additions & 11 deletions activerecord/test/cases/adapters/mysql2/mysql2_adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ def test_exec_query_nothing_raises_with_no_result_queries
end
end

def test_valid_column
with_example_table do
column = @conn.columns("ex").find { |col| col.name == "id" }
assert @conn.valid_type?(column.type)
end
end

def test_invalid_column
assert_not @conn.valid_type?(:foobar)
end

def test_columns_for_distinct_zero_orders
assert_equal "posts.id",
@conn.columns_for_distinct("posts.id", [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ def test_bad_connection
end
end

def test_valid_column
with_example_table do
column = @connection.columns("ex").find { |col| col.name == "id" }
assert @connection.valid_type?(column.type)
end
end

def test_invalid_column
assert_not @connection.valid_type?(:foobar)
end

def test_primary_key
with_example_table do
assert_equal "id", @connection.primary_key("ex")
Expand Down
16 changes: 0 additions & 16 deletions activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,6 @@ def test_connect_memory_with_url
end
end

def test_valid_column
with_example_table do
column = @conn.columns("ex").find { |col| col.name == "id" }
assert @conn.valid_type?(column.type)
end
end

# sqlite3 databases should be able to support any type and not just the
# ones mentioned in the native_database_types.
#
# Therefore test_invalid column should always return true even if the
# type is not valid.
def test_invalid_column
assert @conn.valid_type?(:foobar)
end

def test_column_types
owner = Owner.create!(name: "hello".encode("ascii-8bit"))
owner.reload
Expand Down