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

fix: 渠道多分组,优化分组 like 查询 #415

Merged
merged 4 commits into from
Aug 8, 2024

Conversation

dalefengs
Copy link
Contributor

渠道多分组,优化分组 like 查询
image

@Calcium-Ion
Copy link
Owner

你去掉groupCol会导致pgsql用不了

@dalefengs
Copy link
Contributor Author

sqlite、pgsql 我都测试过了,是正常的。在条件中都为 "group"

AND (',' || "group" || ',') LIKE ?

@Calcium-Ion
Copy link
Owner

Calcium-Ion commented Aug 7, 2024

好的,那mysql呢

@Calcium-Ion Calcium-Ion merged commit 43076c2 into Calcium-Ion:main Aug 8, 2024
@dalefengs dalefengs deleted the fix_group branch August 9, 2024 01:26
@dalefengs
Copy link
Contributor Author

dalefengs commented Aug 9, 2024

好的,那mysql呢

不好意思,没有看到消息。 mysql我还没测。
fix: 修复mysql兼容问题 使用了 CONCAT。 sqlite 不能正常使用

if common.UsingMySQL {
	groupCondition = `CONCAT(',', ` + groupCol + `, ',') LIKE ?`
} else {
	groupCondition = `(',' || ` + groupCol + ` || ',') LIKE ?`
}

或者考虑使用兼容性更好的办法?就是条件会比较长

SELECT *
FROM channels
WHERE group = 'vip' 
   OR group LIKE 'vip,%' 
   OR group LIKE '%,vip' 
   OR group LIKE '%,vip,%' 

@Calcium-Ion
Copy link
Owner

#423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants