Automatically stringify any argument to the collection() method.
FossilOrigin-Name: 749e8ca3a58546682e628af538e735cf0b943d1c845bcb9777a96baaee7f50ac
This commit is contained in:
parent
71ecec82ea
commit
cb23452aea
2 changed files with 12 additions and 1 deletions
|
|
@ -603,7 +603,13 @@ rmdbx_set_subdb( int argc, VALUE *argv, VALUE self )
|
||||||
strcpy( prev_db, db->subdb );
|
strcpy( prev_db, db->subdb );
|
||||||
}
|
}
|
||||||
|
|
||||||
db->subdb = NIL_P( subdb ) ? NULL : StringValueCStr( subdb );
|
if ( NIL_P(subdb) ) {
|
||||||
|
db->subdb = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
subdb = rb_funcall( subdb, rb_intern("to_s"), 0 );
|
||||||
|
db->subdb = StringValueCStr( subdb );
|
||||||
|
}
|
||||||
rmdbx_close_dbi( db );
|
rmdbx_close_dbi( db );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,11 @@ RSpec.describe( MDBX::Database ) do
|
||||||
expect( db['key'] ).to be_truthy
|
expect( db['key'] ).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "automatically stringifies the collection argument" do
|
||||||
|
db.collection( :bucket )
|
||||||
|
expect( db.collection ).to eq( 'bucket' )
|
||||||
|
end
|
||||||
|
|
||||||
it "revert back to the previous collection when used in a block" do
|
it "revert back to the previous collection when used in a block" do
|
||||||
expect( db.collection ).to be_nil
|
expect( db.collection ).to be_nil
|
||||||
db.collection( 'bucket' ) { 'no-op' }
|
db.collection( 'bucket' ) { 'no-op' }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue