Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 MySQL 搭建报错 #29

Closed
ilay1678 opened this issue Apr 27, 2023 · 10 comments
Closed

使用 MySQL 搭建报错 #29

ilay1678 opened this issue Apr 27, 2023 · 10 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@ilay1678
Copy link

[SYS] 2023/04/27 - 01:46:40 | One API v0.1.5 started
[FATAL] 2023/04/27 - 01:46:40 | [Error 1170: BLOB/TEXT column 'key' used in key specification without a key length]

2023/04/27 01:46:40 �[31;1m/build/model/main.go:61 �[35;1mError 1170: BLOB/TEXT column 'key' used in key specification without a key length
�[0m�[33m[4.126ms] �[34;1m[rows:0]�[0m CREATE TABLE tokens (id bigint AUTO_INCREMENT,user_id bigint,key longtext,status bigint DEFAULT 1,name varchar(191),created_time bigint,accessed_time bigint,expired_time bigint DEFAULT -1,remain_times bigint DEFAULT 0,unlimited_times boolean DEFAULT false,PRIMARY KEY (id),UNIQUE INDEX idx_tokens_key (key),INDEX idx_tokens_name (name))

@ilay1678
Copy link
Author

看到刚提交的修复了

@songquanpeng
Copy link
Owner

好的,不过并没有完整测试,期待反馈。

@songquanpeng songquanpeng changed the title 使用mysql搭建报错 使用 MySQL 搭建报错 Apr 27, 2023
@songquanpeng songquanpeng added the duplicate This issue or pull request already exists label Apr 27, 2023
@ilay1678
Copy link
Author

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = ? ORDER BY tokens.id LIMIT 1' at line 1
SELECT * FROM tokens WHERE key = '123456' ORDER BY tokens.id LIMIT 1

@ilay1678 ilay1678 reopened this Apr 27, 2023
@songquanpeng
Copy link
Owner

Okay,收到

@songquanpeng
Copy link
Owner

已推送,v0.1.6-alpha.1

我现在手头没有 MySQL 环境,只在 SQLite 测试了一下,如果方便的话麻烦测试一下,谢谢。

@songquanpeng
Copy link
Owner

另外,貌似你填成令牌的名字而非 key 了,这个 key 都是生成的 UUID 随机字符串。

不过和 MySQL 报错没有关系。

@ilay1678
Copy link
Author

ilay1678 commented Apr 27, 2023

另外,貌似你填成令牌的名字而非 key 了,这个 key 都是生成的 UUID 随机字符串。

不过和 MySQL 报错没有关系。

123456是我手动编辑的 脱敏嘛
1EF37E2F

@songquanpeng
Copy link
Owner

哈哈哈,因为之前碰到两个人把 key 填成名字了。

@songquanpeng songquanpeng added the bug Something isn't working label Apr 27, 2023
@ilay1678
Copy link
Author

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = ? ORDER BY tokens.id LIMIT 1' at line 1 SELECT * FROM tokens WHERE key = '123456' ORDER BY tokens.id LIMIT 1

经测试已修复

@songquanpeng
Copy link
Owner

songquanpeng commented Apr 27, 2023

谢谢,原因在于 key 是 MySQL 的关键字,而 GORM 对此没有任何警告和特殊处理操作。

如果还有其他 MySQL 相关的问题,期待继续反馈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants