Skip to content

Commit db5bd7d

Browse files
authored
Merge pull request astaxie#977 from GeorgeYan/master
Fix: database define column different with query column
2 parents c610e8c + ad25a54 commit db5bd7d

File tree

21 files changed

+42
-42
lines changed

21 files changed

+42
-42
lines changed

de/05.2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ In the following sections, I'll use the same database table structure for differ
2323
CREATE TABLE `userinfo` (
2424
`uid` INT(10) NOT NULL AUTO_INCREMENT,
2525
`username` VARCHAR(64) NULL DEFAULT NULL,
26-
`departname` VARCHAR(64) NULL DEFAULT NULL,
26+
`department` VARCHAR(64) NULL DEFAULT NULL,
2727
`created` DATE NULL DEFAULT NULL,
2828
PRIMARY KEY (`uid`)
2929
);
@@ -43,7 +43,7 @@ The following example shows how to operate on a database based on the `database/
4343
checkErr(err)
4444

4545
// insert
46-
stmt, err := db.Prepare("INSERT userinfo SET username=?,departname=?,created=?")
46+
stmt, err := db.Prepare("INSERT userinfo SET username=?,department=?,created=?")
4747
checkErr(err)
4848

4949
res, err := stmt.Exec("astaxie", "研发部门", "2012-12-09")

de/05.3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ We create the following SQL:
1919
CREATE TABLE `userinfo` (
2020
`uid` INTEGER PRIMARY KEY AUTOINCREMENT,
2121
`username` VARCHAR(64) NULL,
22-
`departname` VARCHAR(64) NULL,
22+
`department` VARCHAR(64) NULL,
2323
`created` DATE NULL
2424
);
2525

@@ -39,7 +39,7 @@ An example:
3939
checkErr(err)
4040

4141
// insert
42-
stmt, err := db.Prepare("INSERT INTO userinfo(username, departname, created) values(?,?,?)")
42+
stmt, err := db.Prepare("INSERT INTO userinfo(username, department, created) values(?,?,?)")
4343
checkErr(err)
4444

4545
res, err := stmt.Exec("astaxie", "研发部门", "2012-12-09")

de/05.4.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ We create the following SQL:
2020
(
2121
uid serial NOT NULL,
2222
username character varying(100) NOT NULL,
23-
departname character varying(500) NOT NULL,
23+
department character varying(500) NOT NULL,
2424
Created date,
2525
CONSTRAINT userinfo_pkey PRIMARY KEY (uid)
2626
)
@@ -53,7 +53,7 @@ An example:
5353
fmt.Println("# Inserting values")
5454

5555
var lastInsertId int
56-
err = db.QueryRow("INSERT INTO userinfo(username,departname,created) VALUES($1,$2,$3) returning uid;", "astaxie", "研发部门", "2012-12-09").Scan(&lastInsertId)
56+
err = db.QueryRow("INSERT INTO userinfo(username,department,created) VALUES($1,$2,$3) returning uid;", "astaxie", "研发部门", "2012-12-09").Scan(&lastInsertId)
5757
checkErr(err)
5858
fmt.Println("last inserted id =", lastInsertId)
5959

en/05.2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In the following sections, I'll use the same database table structure for differ
2222
CREATE TABLE `userinfo` (
2323
`uid` INT(10) NOT NULL AUTO_INCREMENT,
2424
`username` VARCHAR(64) NULL DEFAULT NULL,
25-
`departname` VARCHAR(64) NULL DEFAULT NULL,
25+
`department` VARCHAR(64) NULL DEFAULT NULL,
2626
`created` DATE NULL DEFAULT NULL,
2727
PRIMARY KEY (`uid`)
2828
);
@@ -42,7 +42,7 @@ The following example shows how to operate on a database based on the `database/
4242
checkErr(err)
4343

4444
// insert
45-
stmt, err := db.Prepare("INSERT userinfo SET username=?,departname=?,created=?")
45+
stmt, err := db.Prepare("INSERT userinfo SET username=?,department=?,created=?")
4646
checkErr(err)
4747

4848
res, err := stmt.Exec("astaxie", "研发部门", "2012-12-09")

en/05.3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ We create the following SQL:
1919
CREATE TABLE `userinfo` (
2020
`uid` INTEGER PRIMARY KEY AUTOINCREMENT,
2121
`username` VARCHAR(64) NULL,
22-
`departname` VARCHAR(64) NULL,
22+
`department` VARCHAR(64) NULL,
2323
`created` DATE NULL
2424
);
2525
```
@@ -39,7 +39,7 @@ An example:
3939
checkErr(err)
4040

4141
// insert
42-
stmt, err := db.Prepare("INSERT INTO userinfo(username, departname, created) values(?,?,?)")
42+
stmt, err := db.Prepare("INSERT INTO userinfo(username, department, created) values(?,?,?)")
4343
checkErr(err)
4444

4545
res, err := stmt.Exec("astaxie", "研发部门", "2012-12-09")

en/05.4.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ We create the following SQL:
2020
(
2121
uid serial NOT NULL,
2222
username character varying(100) NOT NULL,
23-
departname character varying(500) NOT NULL,
23+
department character varying(500) NOT NULL,
2424
Created date,
2525
CONSTRAINT userinfo_pkey PRIMARY KEY (uid)
2626
)
@@ -53,7 +53,7 @@ An example:
5353
fmt.Println("# Inserting values")
5454

5555
var lastInsertId int
56-
err = db.QueryRow("INSERT INTO userinfo(username,departname,created) VALUES($1,$2,$3) returning uid;", "astaxie", "研发部门", "2012-12-09").Scan(&lastInsertId)
56+
err = db.QueryRow("INSERT INTO userinfo(username,department,created) VALUES($1,$2,$3) returning uid;", "astaxie", "研发部门", "2012-12-09").Scan(&lastInsertId)
5757
checkErr(err)
5858
fmt.Println("last inserted id =", lastInsertId)
5959

es/05.2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ En las siguientes secciones usaré las misma estructura de tablas para diferente
2222
CREATE TABLE `userinfo` (
2323
`uid` INT(10) NOT NULL AUTO_INCREMENT,
2424
`username` VARCHAR(64) NULL DEFAULT NULL,
25-
`departname` VARCHAR(64) NULL DEFAULT NULL,
25+
`department` VARCHAR(64) NULL DEFAULT NULL,
2626
`created` DATE NULL DEFAULT NULL,
2727
PRIMARY KEY (`uid`)
2828
);
@@ -42,7 +42,7 @@ El siguiente ejemplo muestra como operar en bases de datos con los estándares d
4242
checkErr(err)
4343
4444
// insertar
45-
stmt, err := db.Prepare("INSERT userinfo SET username=?,departname=?,created=?")
45+
stmt, err := db.Prepare("INSERT userinfo SET username=?,department=?,created=?")
4646
checkErr(err)
4747
4848
res, err := stmt.Exec("astaxie", "研发部门", "2012-12-09")

es/05.3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Crearemos el siguiente SQL:
1919
CREATE TABLE `userinfo` (
2020
`uid` INTEGER PRIMARY KEY AUTOINCREMENT,
2121
`username` VARCHAR(64) NULL,
22-
`departname` VARCHAR(64) NULL,
22+
`department` VARCHAR(64) NULL,
2323
`created` DATE NULL
2424
);
2525
```
@@ -39,7 +39,7 @@ Un ejemplo:
3939
checkErr(err)
4040
4141
// insertar
42-
stmt, err := db.Prepare("INSERT INTO userinfo(username, departname, created) values(?,?,?)")
42+
stmt, err := db.Prepare("INSERT INTO userinfo(username, department, created) values(?,?,?)")
4343
checkErr(err)
4444
4545
res, err := stmt.Exec("astaxie", "研发部门", "2012-12-09")

es/05.4.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Crearemos el siguiente SQL:
2020
(
2121
uid serial NOT NULL,
2222
username character varying(100) NOT NULL,
23-
departname character varying(500) NOT NULL,
23+
department character varying(500) NOT NULL,
2424
Created date,
2525
CONSTRAINT userinfo_pkey PRIMARY KEY (uid)
2626
)
@@ -53,7 +53,7 @@ Un ejemplo:
5353
fmt.Println("# Inserting values")
5454
5555
var lastInsertId int
56-
err = db.QueryRow("INSERT INTO userinfo(username,departname,created) VALUES($1,$2,$3) returning uid;", "astaxie", "研发部门", "2012-12-09").Scan(&lastInsertId)
56+
err = db.QueryRow("INSERT INTO userinfo(username,department,created) VALUES($1,$2,$3) returning uid;", "astaxie", "研发部门", "2012-12-09").Scan(&lastInsertId)
5757
checkErr(err)
5858
fmt.Println("last inserted id =", lastInsertId)
5959

ja/05.2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ GoではMySQLをサポートしたドライバが現在比較的多く、以下
2020
CREATE TABLE `userinfo` (
2121
`uid` INT(10) NOT NULL AUTO_INCREMENT,
2222
`username` VARCHAR(64) NULL DEFAULT NULL,
23-
`departname` VARCHAR(64) NULL DEFAULT NULL,
23+
`department` VARCHAR(64) NULL DEFAULT NULL,
2424
`created` DATE NULL DEFAULT NULL,
2525
PRIMARY KEY (`uid`)
2626
)
@@ -48,7 +48,7 @@ GoではMySQLをサポートしたドライバが現在比較的多く、以下
4848
checkErr(err)
4949

5050
//データの挿入
51-
stmt, err := db.Prepare("INSERT userinfo SET username=?,departname=?,created=?")
51+
stmt, err := db.Prepare("INSERT userinfo SET username=?,department=?,created=?")
5252
checkErr(err)
5353

5454
res, err := stmt.Exec("astaxie", "研究開発部門", "2012-12-09")

0 commit comments

Comments
 (0)