Skip to content

Commit 846720a

Browse files
committed
Update to MySQL 8
1 parent cd7bc12 commit 846720a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

dump.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const headerTmpl = `-- Go SQL Dump {{ .DumpVersion }}
3838
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
3939
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
4040
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
41-
/*!40101 SET NAMES utf8 */;
41+
SET NAMES utf8mb4;
4242
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
4343
/*!40103 SET TIME_ZONE='+00:00' */;
4444
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -52,20 +52,21 @@ const tableTmpl = `
5252
-- Table structure for table {{ .Name }}
5353
--
5454
55-
DROP TABLE IF EXISTS {{ .Name }};
55+
DROP TABLE IF EXISTS ` + "`{{ .Name }}`" + `;
5656
/*!40101 SET @saved_cs_client = @@character_set_client */;
57-
/*!40101 SET character_set_client = utf8 */;
57+
SET character_set_client = utf8mb4;
5858
{{ .SQL }};
5959
/*!40101 SET character_set_client = @saved_cs_client */;
60+
6061
--
6162
-- Dumping data for table {{ .Name }}
6263
--
6364
6465
LOCK TABLES {{ .Name }} WRITE;
6566
/*!40000 ALTER TABLE {{ .Name }} DISABLE KEYS */;
66-
{{ if .Values }}
67+
{{- if .Values }}
6768
INSERT INTO {{ .Name }} VALUES {{ .Values }};
68-
{{ end }}
69+
{{- end }}
6970
/*!40000 ALTER TABLE {{ .Name }} ENABLE KEYS */;
7071
UNLOCK TABLES;
7172
`

dump_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,34 +298,31 @@ func TestDumpOk(t *testing.T) {
298298
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
299299
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
300300
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
301-
/*!40101 SET NAMES utf8 */;
301+
SET NAMES utf8mb4;
302302
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
303303
/*!40103 SET TIME_ZONE='+00:00' */;
304304
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
305305
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
306306
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
307307
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
308308
309-
310-
311309
--
312310
-- Table structure for table Test_Table
313311
--
314312
315-
DROP TABLE IF EXISTS Test_Table;
313+
DROP TABLE IF EXISTS \Test_Table\;
316314
/*!40101 SET @saved_cs_client = @@character_set_client */;
317-
/*!40101 SET character_set_client = utf8 */;
315+
SET character_set_client = utf8mb4;
318316
CREATE TABLE 'Test_Table' (\id\ int(11) NOT NULL AUTO_INCREMENT,\email\ char(60) DEFAULT NULL, \name\ char(60), PRIMARY KEY (\id\))ENGINE=InnoDB DEFAULT CHARSET=latin1;
319317
/*!40101 SET character_set_client = @saved_cs_client */;
318+
320319
--
321320
-- Dumping data for table Test_Table
322321
--
323322
324323
LOCK TABLES Test_Table WRITE;
325324
/*!40000 ALTER TABLE Test_Table DISABLE KEYS */;
326-
327325
INSERT INTO Test_Table VALUES ('1',null,'Test Name 1'),('2','[email protected]','Test Name 2');
328-
329326
/*!40000 ALTER TABLE Test_Table ENABLE KEYS */;
330327
UNLOCK TABLES;
331328

0 commit comments

Comments
 (0)