Skip to content

Commit

Permalink
Merge pull request #101 from HeyNonster/nony--add-select-db-alias
Browse files Browse the repository at this point in the history
Add `select_db` as an alias for `change_db`
  • Loading branch information
jhawthorn authored Aug 2, 2023
2 parents 99cc348 + d728293 commit a97c8d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/ruby/ext/trilogy-ruby/cext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,7 @@ RUBY_FUNC_EXPORTED void Init_cext()

rb_define_private_method(Trilogy, "_initialize", rb_trilogy_initialize, 3);
rb_define_method(Trilogy, "change_db", rb_trilogy_change_db, 1);
rb_define_alias(Trilogy, "select_db", "change_db");
rb_define_method(Trilogy, "query", rb_trilogy_query, 1);
rb_define_method(Trilogy, "ping", rb_trilogy_ping, 0);
rb_define_method(Trilogy, "escape", rb_trilogy_escape, 1);
Expand Down
9 changes: 9 additions & 0 deletions contrib/ruby/test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ def test_trilogy_change_db
ensure_closed client
end

# select_db is just an alias for change_db
# and is tested here to ensure it works.
def test_trilogy_select_db
client = new_tcp_client
assert client.select_db "test"
ensure
ensure_closed client
end

def test_trilogy_change_db_after_close_raises
client = new_tcp_client
assert client.change_db "test"
Expand Down

0 comments on commit a97c8d3

Please sign in to comment.