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

Fixes to sqlite dialect: do not add FOR UPDATE in SELECT, fix support for INSERT ON CONFLICT #218

Merged
merged 4 commits into from
May 21, 2020
Merged

Fixes to sqlite dialect: do not add FOR UPDATE in SELECT, fix support for INSERT ON CONFLICT #218

merged 4 commits into from
May 21, 2020

Conversation

vlanse
Copy link
Contributor

@vlanse vlanse commented May 15, 2020

SQLite lacks support of SELECT FOR UPDATE: https://sqlite.org/lang_select.html

To enable cross-database queries building with that syntax and avoid additional conditions in application code, need to insert empty fragment for SQLite dialect

@@ -121,6 +121,7 @@ if err != nil{
Output:
```
SELECT * FROM "test" WHERE "id" = 10 []
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover from my previous PR with sqlserver support :)

@codecov
Copy link

codecov bot commented May 15, 2020

Codecov Report

Merging #218 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #218   +/-   ##
=======================================
  Coverage   96.51%   96.51%           
=======================================
  Files          60       60           
  Lines        4189     4195    +6     
=======================================
+ Hits         4043     4049    +6     
  Misses        131      131           
  Partials       15       15           
Impacted Files Coverage Δ
dialect/sqlite3/sqlite3.go 100.00% <100.00%> (ø)
sql_dialect.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 417f438...53fb654. Read the comment docs.

)

func init() {
RegisterDialect("default", DefaultDialectOptions())
}

func RegisterDialect(name string, do *SQLDialectOptions) {
dialectsMu.Lock()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to this: https://github.com/golang/go/blob/master/src/database/sql/sql.go#L45
faced problem with concurrent map writes in our test environment

@vlanse vlanse changed the title SQLite does not support FOR UPDATE syntax, so use empty fragment for it Fixes to sqlite dialect: do not add FOR UPDATE in SELECT, fix support for INSERT ON CONFLICT May 19, 2020
@vlanse
Copy link
Contributor Author

vlanse commented May 20, 2020

@doug-martin could you please proceed with review?

@doug-martin doug-martin merged commit 65f17f3 into doug-martin:master May 21, 2020
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