Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

关于连接 PostgreSQL 问题 #16

Closed
qwqcode opened this issue Feb 26, 2022 · 2 comments
Closed

关于连接 PostgreSQL 问题 #16

qwqcode opened this issue Feb 26, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@qwqcode
Copy link
Member

qwqcode commented Feb 26, 2022

image

由于 model 定义了很多 boolean 类型的字段,使用 gorm 进行查询 where 方法查询很多地方直接传递了字符串 xxx = 1,在 MySQL 数据库和 SQLite 下 gorm 拼接的语句能正常工作。

参考:f420fb5

然而,由于 pgsql 字段类型丰富,自带 boolean 字段类型;而 MySQL 本身无,故 gorm 创建字段类型 tinyint 来替代。导致了 pgsql 数据库和 MySQL 查询语句的差异性。

解决办法:将所有 boolean 字段类型改成 int,消除 gorm 创建 table 在不同数据库间的类型差异性。

另外还有很多问题,MySQL 和 SQLite 外键约束功能正常,而 PgSQL 测试不正常。

参考:go-gorm/gorm#3624

适配难度较大,需要一定的时间和精力,暂时搁置。

目前仅测试兼容 MySQL 和 SQLite 两种数据库。

@qwqcode qwqcode added the bug Something isn't working label Feb 26, 2022
@qwqcode qwqcode closed this as completed Feb 26, 2022
@qwqcode qwqcode pinned this issue Feb 26, 2022
@weijie-he
Copy link

这个问题我看 waline 那边是为不同的数据源写了不同的建表语句。也许你可以参考一下
walinejs

@qwqcode qwqcode unpinned this issue Apr 20, 2022
@qwqcode
Copy link
Member Author

qwqcode commented Apr 23, 2022

v2.1.3 已兼容 PostgreSQL
https://github.com/ArtalkJS/ArtalkGo/releases/tag/v2.1.3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants