fix(mssql): fix mssql tool kind to mssql-sql (#249)

Fixing `mssql` tool to `mssql-sql`.
This commit is contained in:
Yuan
2025-01-29 15:46:01 -08:00
committed by GitHub
parent 669d6b7239
commit 1357be2569
6 changed files with 19 additions and 19 deletions

View File

@@ -29,7 +29,7 @@ import (
postgressrc "github.com/googleapis/genai-toolbox/internal/sources/postgres"
spannersrc "github.com/googleapis/genai-toolbox/internal/sources/spanner"
"github.com/googleapis/genai-toolbox/internal/tools"
"github.com/googleapis/genai-toolbox/internal/tools/mssql"
"github.com/googleapis/genai-toolbox/internal/tools/mssqlsql"
"github.com/googleapis/genai-toolbox/internal/tools/mysqlsql"
neo4jtool "github.com/googleapis/genai-toolbox/internal/tools/neo4j"
"github.com/googleapis/genai-toolbox/internal/tools/postgressql"
@@ -272,8 +272,8 @@ func (c *ToolConfigs) UnmarshalYAML(unmarshal func(interface{}) error) error {
return fmt.Errorf("unable to parse as %q: %w", k.Kind, err)
}
(*c)[name] = actual
case mssql.ToolKind:
actual := mssql.Config{Name: name}
case mssqlsql.ToolKind:
actual := mssqlsql.Config{Name: name}
if err := u.Unmarshal(&actual); err != nil {
return fmt.Errorf("unable to parse as %q: %w", k.Kind, err)
}

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package mssql
package mssqlsql
import (
"database/sql"
@@ -24,7 +24,7 @@ import (
"github.com/googleapis/genai-toolbox/internal/tools"
)
const ToolKind string = "mssql"
const ToolKind string = "mssql-sql"
type compatibleSource interface {
MSSQLDB() *sql.DB

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package mssql_test
package mssqlsql_test
import (
"testing"
@@ -21,7 +21,7 @@ import (
"github.com/googleapis/genai-toolbox/internal/server"
"github.com/googleapis/genai-toolbox/internal/testutils"
"github.com/googleapis/genai-toolbox/internal/tools"
"github.com/googleapis/genai-toolbox/internal/tools/mssql"
"github.com/googleapis/genai-toolbox/internal/tools/mssqlsql"
"gopkg.in/yaml.v3"
)
@@ -36,7 +36,7 @@ func TestParseFromYamlMssql(t *testing.T) {
in: `
tools:
example_tool:
kind: mssql
kind: mssql-sql
source: my-instance
description: some description
statement: |
@@ -55,9 +55,9 @@ func TestParseFromYamlMssql(t *testing.T) {
field: user_id
`,
want: server.ToolConfigs{
"example_tool": mssql.Config{
"example_tool": mssqlsql.Config{
Name: "example_tool",
Kind: mssql.ToolKind,
Kind: mssqlsql.ToolKind,
Source: "my-instance",
Description: "some description",
Statement: "SELECT * FROM SQL_STATEMENT;\n",

View File

@@ -63,7 +63,7 @@ func RunGoogleAuthenticatedParameterTest(t *testing.T, sourceConfig map[string]a
switch {
case strings.EqualFold(toolKind, "postgres-sql"):
statement = fmt.Sprintf("SELECT * FROM %s WHERE email = $1;", tableName)
case strings.EqualFold(toolKind, "mssql"):
case strings.EqualFold(toolKind, "mssql-sql"):
statement = fmt.Sprintf("SELECT * FROM %s WHERE email = @email;", tableName)
default:
t.Fatalf("invalid tool kind: %s", toolKind)
@@ -132,7 +132,7 @@ func RunGoogleAuthenticatedParameterTest(t *testing.T, sourceConfig map[string]a
// Tools using database/sql interface only outputs `int64` instead of `int32`
var wantString string
switch toolKind {
case "mssql":
case "mssql-sql":
wantString = fmt.Sprintf("Stub tool call for \"my-auth-tool\"! Parameters parsed: [{\"email\" \"%s\"}] \n Output: [%%!s(int64=1) Alice %s]", SERVICE_ACCOUNT_EMAIL, SERVICE_ACCOUNT_EMAIL)
default:
wantString = fmt.Sprintf("Stub tool call for \"my-auth-tool\"! Parameters parsed: [{\"email\" \"%s\"}] \n Output: [%%!s(int32=1) Alice %s]", SERVICE_ACCOUNT_EMAIL, SERVICE_ACCOUNT_EMAIL)
@@ -216,7 +216,7 @@ func RunAuthRequiredToolInvocationTest(t *testing.T, sourceConfig map[string]any
// Tools using database/sql interface only outputs `int64` instead of `int32`
var wantString string
switch toolKind {
case "mssql":
case "mssql-sql":
wantString = "Stub tool call for \"my-auth-tool\"! Parameters parsed: [] \n Output: [%!s(int64=1)]"
default:
wantString = "Stub tool call for \"my-auth-tool\"! Parameters parsed: [] \n Output: [%!s(int32=1)]"

View File

@@ -133,7 +133,7 @@ func TestCloudSQLMssql(t *testing.T) {
},
"tools": map[string]any{
"my-simple-tool": map[string]any{
"kind": "mssql",
"kind": "mssql-sql",
"source": "my-instance",
"description": "Simple tool to test end to end functionality.",
"statement": "SELECT 1;",
@@ -300,7 +300,7 @@ func TestToolInvocationWithParams(t *testing.T) {
defer teardownTest(t)
// call generic invocation test helper
RunToolInvocationWithParamsTest(t, sourceConfig, "mssql", tableName)
RunToolInvocationWithParamsTest(t, sourceConfig, "mssql-sql", tableName)
}
// Set up auth test database table
@@ -362,7 +362,7 @@ func TestCloudSQLMssqlGoogleAuthenticatedParameter(t *testing.T) {
defer teardownTest(t)
// call generic auth test helper
RunGoogleAuthenticatedParameterTest(t, sourceConfig, "mssql", tableName)
RunGoogleAuthenticatedParameterTest(t, sourceConfig, "mssql-sql", tableName)
}
@@ -371,6 +371,6 @@ func TestCloudSQLMssqlAuthRequiredToolInvocation(t *testing.T) {
sourceConfig := requireCloudSQLMssqlVars(t)
// call generic auth test helper
RunAuthRequiredToolInvocationTest(t, sourceConfig, "mssql")
RunAuthRequiredToolInvocationTest(t, sourceConfig, "mssql-sql")
}

View File

@@ -215,7 +215,7 @@ func RunToolInvocationWithParamsTest(t *testing.T, sourceConfig map[string]any,
switch toolKind {
case "postgres-sql":
statement = fmt.Sprintf("SELECT * FROM %s WHERE id = $1 OR name = $2;", tableName)
case "mssql":
case "mssql-sql":
statement = fmt.Sprintf("SELECT * FROM %s WHERE id = @id OR name = @p2;", tableName)
default:
t.Fatalf("invalid tool kind: %s", toolKind)
@@ -224,7 +224,7 @@ func RunToolInvocationWithParamsTest(t *testing.T, sourceConfig map[string]any,
// Tools using database/sql interface only outputs `int64` instead of `int32`
var wantString string
switch toolKind {
case "mssql":
case "mssql-sql":
wantString = "Stub tool call for \"my-tool\"! Parameters parsed: [{\"id\" '\\x03'} {\"name\" \"Alice\"}] \n Output: [%!s(int64=1) Alice][%!s(int64=3) Sid]"
default:
wantString = "Stub tool call for \"my-tool\"! Parameters parsed: [{\"id\" '\\x03'} {\"name\" \"Alice\"}] \n Output: [%!s(int32=1) Alice][%!s(int32=3) Sid]"