Skip to content

Commit ec22400

Browse files
authored
Merge pull request #1033 from yellowspot/add-ruby-3.2
Support proc default values in ruby 3.2
2 parents 2094cab + 3af0407 commit ec22400

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#### Fixed
44

55
- [#1029](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1029) Handle views defined in other databases.
6+
- [#1033](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1033) Support proc default values in ruby 3.2.
7+
68

79
#### Changed
810

lib/active_record/connection_adapters/sqlserver/quoting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def quote_column_name(name)
3939

4040
def quote_default_expression(value, column)
4141
cast_type = lookup_cast_type(column.sql_type)
42-
if cast_type.type == :uuid && value =~ /\(\)/
42+
if cast_type.type == :uuid && value.is_a?(String) && value.include?('()')
4343
value
4444
else
4545
super

test/cases/uuid_test_sqlserver.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,12 @@ class SQLServerUuidTest < ActiveRecord::TestCase
4343
obj = with_use_output_inserted_disabled { SSTestUuid.create!(name: "😢") }
4444
_(obj.id).must_be :nil?
4545
end
46+
47+
it "can add column with proc as default" do
48+
table_name = SSTestUuid.table_name
49+
connection.add_column table_name, :thingy, :uuid, null: false, default: -> { "NEWSEQUENTIALID()" }
50+
SSTestUuid.reset_column_information
51+
column = SSTestUuid.columns_hash["thingy"]
52+
_(column.default_function).must_equal "newsequentialid()"
53+
end
4654
end

0 commit comments

Comments
 (0)