forked from JamesStewy/go-mysqldump
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request JamesStewy#11 from christianruhstaller/bugfix-nil
Add handling for nil values
- Loading branch information
Showing
2 changed files
with
9 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,8 @@ func TestCreateTableValuesNil(t *testing.T) { | |
|
||
rows := sqlmock.NewRows([]string{"id", "email", "name"}). | ||
AddRow(1, nil, "Test Name 1"). | ||
AddRow(2, "[email protected]", "Test Name 2") | ||
AddRow(2, "[email protected]", "Test Name 2"). | ||
AddRow(3, "", "Test Name 3") | ||
|
||
mock.ExpectQuery("^SELECT (.+) FROM test$").WillReturnRows(rows) | ||
|
||
|
@@ -189,7 +190,7 @@ func TestCreateTableValuesNil(t *testing.T) { | |
t.Errorf("there were unfulfilled expections: %s", err) | ||
} | ||
|
||
expectedResult := "('1','','Test Name 1'),('2','[email protected]','Test Name 2')" | ||
expectedResult := "('1',null,'Test Name 1'),('2','[email protected]','Test Name 2'),('3','','Test Name 3')" | ||
|
||
if !reflect.DeepEqual(result, expectedResult) { | ||
t.Fatalf("expected %#v, got %#v", expectedResult, result) | ||
|
@@ -227,7 +228,7 @@ func TestCreateTableOk(t *testing.T) { | |
expectedResult := &table{ | ||
Name: "Test_Table", | ||
SQL: "CREATE TABLE 'Test_Table' (`id` int(11) NOT NULL AUTO_INCREMENT,`s` char(60) DEFAULT NULL, PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1", | ||
Values: "('1','','Test Name 1'),('2','[email protected]','Test Name 2')", | ||
Values: "('1',null,'Test Name 1'),('2','[email protected]','Test Name 2')", | ||
} | ||
|
||
if !reflect.DeepEqual(result, expectedResult) { | ||
|
@@ -323,7 +324,7 @@ CREATE TABLE 'Test_Table' (\id\ int(11) NOT NULL AUTO_INCREMENT,\email\ char(60) | |
LOCK TABLES Test_Table WRITE; | ||
/*!40000 ALTER TABLE Test_Table DISABLE KEYS */; | ||
INSERT INTO Test_Table VALUES ('1','','Test Name 1'),('2','[email protected]','Test Name 2'); | ||
INSERT INTO Test_Table VALUES ('1',null,'Test Name 1'),('2','[email protected]','Test Name 2'); | ||
/*!40000 ALTER TABLE Test_Table ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
|