Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bulkcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ func (b *Bulk) sendBulkCommand(ctx context.Context) (err error) {

//columns definitions
var col_defs bytes.Buffer
q := TSQLQuoter{}
for i, col := range b.bulkColumns {
if i != 0 {
col_defs.WriteString(", ")
}
col_defs.WriteString("[" + col.ColName + "] " + makeDecl(col.ti))
col_defs.WriteString(q.ID(col.ColName) + " " + makeDecl(col.ti))
}

//options
Expand Down
11 changes: 10 additions & 1 deletion bulkcopy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func testBulkcopy(t *testing.T, guidConversion bool) {
{"test_int16nvarchar", int16(1234), "1234"},
{"test_int8nvarchar", int8(12), "12"},
{"test_intnvarchar", 1234, "1234"},
{"test_[]{}?@!#$%^&*()_+-=~'\\\";:/.,<>|\\ ", 1, nil}, // col name escaping check
}

columns := make([]string, len(testValues))
Expand Down Expand Up @@ -265,8 +266,14 @@ func testBulkcopy(t *testing.T, guidConversion bool) {
t.Errorf("unexpected row count %d", rowCount)
}

q := TSQLQuoter{}
selectColumns := make([]string, len(columns))
for i, col := range columns {
selectColumns[i] = q.ID(col)
}

//data verification
rows, err := conn.QueryContext(ctx, "select "+strings.Join(columns, ",")+" from "+tableName)
rows, err := conn.QueryContext(ctx, "select "+strings.Join(selectColumns, ",")+" from "+tableName)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -435,6 +442,8 @@ func setupTable(ctx context.Context, t *testing.T, conn *sql.Conn, tableName str
[test_nullint32] [int] NULL,
[test_nullint16] [smallint] NULL,
[test_nulltime] [datetime] NULL,

[test_[]]{}?@!#$%^&*()_+-=~'\";:/.,<>|\ ] [int] NULL,
CONSTRAINT [PK_` + tableName + `_id] PRIMARY KEY CLUSTERED
(
[id] ASC
Expand Down
2 changes: 1 addition & 1 deletion lastinsertid_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// This example shows the usage of Connector type
func ExampleLastInsertId() {
func ExampleResult_LastInsertId() {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this name change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connString := makeConnURL().String()

Expand Down
Loading