Skip to content

Commit

Permalink
Undefine T_DATA allocators for Ruby 3.2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Jan 17, 2022
1 parent 25c42c7 commit 6c4e8be
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
1 change: 1 addition & 0 deletions ext/mysql2/result.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ void init_mysql2_result() {
rb_global_variable(&cDateTime);

cMysql2Result = rb_define_class_under(mMysql2, "Result", rb_cObject);
rb_undef_alloc_func(cMysql2Result);
rb_global_variable(&cMysql2Result);

rb_define_method(cMysql2Result, "each", rb_mysql_result_each, -1);
Expand Down
1 change: 1 addition & 0 deletions ext/mysql2/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ void init_mysql2_statement() {
rb_global_variable(&cBigDecimal);

cMysql2Statement = rb_define_class_under(mMysql2, "Statement", rb_cObject);
rb_undef_alloc_func(cMysql2Statement);
rb_global_variable(&cMysql2Statement);

rb_define_method(cMysql2Statement, "param_count", rb_mysql_stmt_param_count, 0);
Expand Down
13 changes: 2 additions & 11 deletions spec/mysql2/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@
end

it "should raise a TypeError exception when it doesn't wrap a result set" do
if RUBY_VERSION >= "3.1"
expect { Mysql2::Result.new }.to raise_error(TypeError)
expect { Mysql2::Result.allocate }.to raise_error(TypeError)
else
r = Mysql2::Result.new
expect { r.count }.to raise_error(TypeError)
expect { r.fields }.to raise_error(TypeError)
expect { r.field_types }.to raise_error(TypeError)
expect { r.size }.to raise_error(TypeError)
expect { r.each }.to raise_error(TypeError)
end
expect { Mysql2::Result.new }.to raise_error(TypeError)
expect { Mysql2::Result.allocate }.to raise_error(TypeError)
end

it "should have included Enumerable" do
Expand Down

0 comments on commit 6c4e8be

Please sign in to comment.