GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat: Generate read-only Queries by jarri-abidi · Pull Request #3291 · sqlc-dev/sqlc Conversation
|
| if !strings.Contains(qsql, "SELECT") { | ||
| continue | ||
| } | ||
| if strings.Contains(qsql, "UPDATE") || strings.Contains(qsql, "INSERT") { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we also check for delete as well if queries have
something like
DELETE FROM your_table
WHERE some_condition IN (
SELECT some_column
FROM another_table
WHERE your_condition
);
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| rq = append(rq, q) | ||
| } | ||
| return rq | ||
| } |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we do it something like this
func readOnly(queries []Query) []Query {
var rq []Query
for _, q := range queries {
if !q.hasRetType() {
continue
}
qsql := strings.ToUpper(q.SQL)
if !containsOnlyAllowedKeywords(qsql) {
continue
}
rq = append(rq, q)
}
return rq
}
func containsOnlyAllowedKeywords(query string) bool {
keywords := []string{"INSERT", "UPDATE", "DELETE","CREATE","ALTER"} // and the other keywords
for _, keyword := range keywords {
if strings.Contains(qsql, keyword) {
return false
}
}
return true
}
So that we can define the list of exluded words
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
queries wont/shouldn't have ddl. so we can rule out CREATE and ALTER
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
hey @kyleconroy can i get a review on this? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@kyleconroy is this good to go? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
bump @kyleconroy |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
bump @kyleconroy |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
bump @kyleconroy |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
bump @kyleconroy I am also interested in this feature! @jarri-abidi maybe you want to make the piplines work, I think thats the reason why its not being merged. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🤖 Automated message This PR has been closed because it has merge conflicts with Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.