Skip to content

Commit

Permalink
sql/mssql: fixed argument placeholder (#1803)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored Jun 29, 2023
1 parent 52e718d commit 4c73312
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions sql/mssql/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (i *inspect) schemas(ctx context.Context, opts *schema.InspectRealmOption)
case n == 1 && opts.Schemas[0] == "":
query = fmt.Sprintf(schemasQueryArgs, "= SCHEMA_NAME()")
case n == 1 && opts.Schemas[0] != "":
query = fmt.Sprintf(schemasQueryArgs, "= @1")
query = fmt.Sprintf(schemasQueryArgs, "= @p1")
args = append(args, opts.Schemas[0])
case n > 0:
query = fmt.Sprintf(schemasQueryArgs, "IN ("+nArgs(0, len(opts.Schemas))+")")
Expand Down Expand Up @@ -438,7 +438,7 @@ func nArgs(start, n int) string {
if i > 1 {
b.WriteString(", ")
}
b.WriteByte('@')
b.WriteString("@p")
b.WriteString(strconv.Itoa(start + i))
}
return b.String()
Expand Down Expand Up @@ -584,7 +584,7 @@ FROM
AND [cd].[class_desc] = N'OBJECT_OR_COLUMN'
AND [cd].[name] = N'MS_Description'
WHERE
SCHEMA_NAME([t1].[schema_id]) = @1
SCHEMA_NAME([t1].[schema_id]) = @p1
AND [t1].[name] IN (%s)
AND [t1].[type] = 'U'
AND [t1].[is_ms_shipped] = 0
Expand Down Expand Up @@ -624,7 +624,7 @@ WHERE
FROM
[sys].[tables] [t1]
WHERE
SCHEMA_NAME([t1].[schema_id]) = @1
SCHEMA_NAME([t1].[schema_id]) = @p1
AND [t1].[name] IN (%s)
)
ORDER BY
Expand Down Expand Up @@ -656,7 +656,7 @@ FROM
AND [cr].[column_id] = [fkc].[referenced_column_id]
WHERE
[fk].[is_ms_shipped] = 0
AND SCHEMA_NAME([fk].[schema_id]) = @1
AND SCHEMA_NAME([fk].[schema_id]) = @p1
AND OBJECT_NAME([fk].[parent_object_id]) IN (%s)
ORDER BY
[table_schema], [constraint_name], [fk].[key_index_id]`
Expand All @@ -673,7 +673,7 @@ FROM
ON [c1].[object_id] = [cc].[parent_object_id]
AND [c1].column_id = [cc].[parent_column_id]
WHERE
SCHEMA_NAME([cc].[schema_id]) = @1
SCHEMA_NAME([cc].[schema_id]) = @p1
AND OBJECT_NAME([cc].[parent_object_id]) IN (%s)
ORDER BY
[cc].[name]`
Expand Down
2 changes: 1 addition & 1 deletion sql/mssql/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

// Single table queries used by the different tests.
var (
queryTable = sqltest.Escape(fmt.Sprintf(tablesQuery, "@1"))
queryTable = sqltest.Escape(fmt.Sprintf(tablesQuery, "@p1"))
)

func TestDriver_InspectSchema(t *testing.T) {
Expand Down

0 comments on commit 4c73312

Please sign in to comment.