提交 63ace8fc 编写于 作者: R Ryuta Kamizono

Merge pull request #36404 from mrschuster/sqlite3_collation_bug

Fix sqlite3 collation parsing when using decimal columns.
上级 765403c7
* Fix sqlite3 collation parsing when using decimal columns.
*Martin R. Schuster*
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
Fixes #36465.
......
......@@ -525,9 +525,9 @@ def table_structure_with_collation(table_name, basic_structure)
result = exec_query(sql, "SCHEMA").first
if result
# Splitting with left parentheses and picking up last will return all
# Splitting with left parentheses and discarding the first part will return all
# columns separated with comma(,).
columns_string = result["sql"].split("(").last
columns_string = result["sql"].split("(", 2).last
columns_string.split(",").each do |column_string|
# This regex will match the column name and collation type and will save
......
......@@ -11,6 +11,10 @@ def setup
@connection.create_table :collation_table_sqlite3, force: true do |t|
t.string :string_nocase, collation: "NOCASE"
t.text :text_rtrim, collation: "RTRIM"
# The decimal column might interfere with collation parsing.
# Thus, add this column type and some other string column afterwards.
t.decimal :decimal_col, precision: 6, scale: 2
t.string :string_after_decimal_nocase, collation: "NOCASE"
end
end
......@@ -22,6 +26,11 @@ def teardown
column = @connection.columns(:collation_table_sqlite3).find { |c| c.name == "string_nocase" }
assert_equal :string, column.type
assert_equal "NOCASE", column.collation
# Verify collation of a column behind the decimal column as well.
column = @connection.columns(:collation_table_sqlite3).find { |c| c.name == "string_after_decimal_nocase" }
assert_equal :string, column.type
assert_equal "NOCASE", column.collation
end
test "text column with collation" do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册