forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logic for working with Tarantool schema via Box
- Implemented the `box.Schema()` method that returns a `Schema` object for schema-related operations
- Loading branch information
maksim.konovalov
committed
Jan 23, 2025
1 parent
d8e2284
commit a492cb5
Showing
13 changed files
with
1,392 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package box | ||
|
||
import "github.com/tarantool/go-tarantool/v2" | ||
|
||
// Schema represents the schema-related operations in Tarantool. | ||
// It holds a connection to interact with the Tarantool instance. | ||
type Schema struct { | ||
conn tarantool.Doer // Connection interface for interacting with Tarantool. | ||
} | ||
|
||
// NewSchema creates a new Schema instance with the provided Tarantool connection. | ||
// It initializes a Schema object that can be used for schema-related operations | ||
// such as managing users, tables, and other schema elements in the Tarantool instance. | ||
func NewSchema(conn tarantool.Doer) *Schema { | ||
return &Schema{conn: conn} // Pass the connection to the Schema. | ||
} | ||
|
||
// User returns a new SchemaUser instance, allowing schema-related user operations. | ||
func (s *Schema) User() *SchemaUser { | ||
return NewSchemaUser(s.conn) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package box | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewSchema(t *testing.T) { | ||
// Create a schema instance with a nil connection. This should lead to a panic later. | ||
b := NewSchema(nil) | ||
|
||
// Ensure the schema is not nil (which it shouldn't be), but this is not meaningful | ||
// since we will panic when we call the schema methods with the nil connection. | ||
require.NotNil(t, b) | ||
} |
Oops, something went wrong.