导出sql后再导入时失败了 #1231

Closed
opened 2019-02-15 05:39:31 +00:00 by buexplain · 1 comment
buexplain commented 2019-02-15 05:39:31 +00:00 (Migrated from github.com)

导出的sql语句:

INSERT INTO `RBACNode` (`ID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, `Pid`, `Name`, `URL`, `SortID`, `IsNav`) VALUES (41, '2019-01-25 19:02:21', '2019-01-25 19:02:31', NULL, 0, '日志管理', 'javascript:;', 1991, 1);

使用engine.Import(r io.Reader)导入的时候失败了,提示是:unrecognized token: "'javascript:"
建议解决办法:
此处代码

if i := bytes.IndexByte(data, ';'); i >= 0 {
    return i + 1, data[0:i], nil
}

改为:

if i := bytes.Index(data, []byte(";\n")); i >= 0 {
    return i + 2, data[0:i], nil
}
导出的sql语句: ```sql INSERT INTO `RBACNode` (`ID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, `Pid`, `Name`, `URL`, `SortID`, `IsNav`) VALUES (41, '2019-01-25 19:02:21', '2019-01-25 19:02:31', NULL, 0, '日志管理', 'javascript:;', 1991, 1); ``` 使用```engine.Import(r io.Reader)```导入的时候失败了,提示是:```unrecognized token: "'javascript:"```。 建议解决办法: [此处代码](https://github.com/go-xorm/xorm/blob/master/engine.go#L1518)由 ```golang if i := bytes.IndexByte(data, ';'); i >= 0 { return i + 1, data[0:i], nil } ``` 改为: ```golang if i := bytes.Index(data, []byte(";\n")); i >= 0 { return i + 2, data[0:i], nil } ```
lunny added this to the 1.1.1 milestone 2020-03-04 02:20:27 +00:00

duplicated with #772

duplicated with #772
lunny closed this issue 2020-03-09 02:13:53 +00:00
lunny removed this from the 1.1.1 milestone 2020-03-09 02:13:57 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1231
No description provided.