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

sqlite driver suppor save #2764

Closed
lusson-luo opened this issue Jul 13, 2023 · 4 comments · Fixed by #3315
Closed

sqlite driver suppor save #2764

lusson-luo opened this issue Jul 13, 2023 · 4 comments · Fixed by #3315
Assignees
Labels
enhancement help wanted planned This issue/proposal is planned into our next steps.

Comments

@lusson-luo
Copy link
Contributor

1. What version of Go and system type/arch are you using?

go 1.20

2. What version of GoFrame are you using?

gf 2.4.2

3. Can this issue be re-produced with the latest release?

yes

4. What did you do?

sqilte driver don't allow to insert and replace

Save operation is not supported by sqlite driver
1. Save operation is not supported by sqlite driver
   1).  github.com/gogf/gf/contrib/drivers/sqlite/v2.(*Driver).DoInsert
        /Users/marxluo/go/src/lusson.cc/gogf/gf/contrib/drivers/sqlite/sqlite.go:183

actually, sqlite support this feature in 3.24.0(2018)https://www.sqlite.org/releaselog/3_24_0.html
so, sqilte driver should allow save method

5. What did you expect to see?

sqilte driver should allow save method

6. What did you see instead?

no

@gqcn
Copy link
Member

gqcn commented Sep 21, 2023

@lusson-luo It's great! It then needs some contributor make the pr.

@gqcn gqcn added enhancement help wanted planned This issue/proposal is planned into our next steps. labels Sep 21, 2023
@github-actions
Copy link

Hello @lusson-luo. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!
你好 @lusson-luo。我们喜欢您的提案/反馈,并希望您或其他社区成员通过拉取请求做出贡献。我们提前感谢您的贡献,并期待对其进行审查。

@lusson-luo
Copy link
Contributor Author

有两个思路可以实现,1. 采用 insert or replace 方式替代 save 方法。2. 采用 insert ... CONFLICT(xxx) set xxx=xxx。
第二种方式有个问题,sqlite 需要指明冲突的键名,不能冲突就替换,目前无法知道哪些列是冲突,用不了。
第一种方式replace目前有相关,sqlite 的save直接调用 replace 也行,改动最小。
@gqcn 您看看采取那种方式比较好
insert ... CONFLICT 参考教程:https://www.sqlite.org/lang_upsert.html

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


There are two ideas to achieve this. 1. Use insert or replace method instead of save method. 2. Use insert ... CONFLICT(xxx) set xxx=xxx.
There is a problem with the second method. SQLite needs to specify the conflicting key name. If it cannot conflict, replace it. Currently, it is impossible to know which columns are conflicting and cannot be used.
The first method, replace, is currently relevant. SQLite's save can also call replace directly, with minimal changes.
@gqcn Which approach is better?
insert... CONFLICT reference tutorial: https://www.sqlite.org/lang_upsert.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted planned This issue/proposal is planned into our next steps.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants