File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -247,12 +247,11 @@ func (p *Plugin) invalidateDML(ctx context.Context, query string) {
247247 p .Logger .Trace ("Query message" , "query" , queryMessage )
248248
249249 queryString := strings .ToUpper (queryMessage ["String" ])
250- // TODO: Add change detection for all changes to DB, not just for the DMLs.
251- // https://github.com/gatewayd-io/gatewayd-plugin-cache/issues/19
252- if ! strings .HasPrefix (queryString , "UPDATE" ) ||
253- ! strings .HasPrefix (queryString , "INSERT" ) ||
254- ! strings .HasPrefix (queryString , "DELETE" ) {
255- p .Logger .Debug ("Query is not a DML. Skipping invalidation" )
250+ // Ignore SELECT and WITH/SELECT queries.
251+ // TODO: This is a naive approach, but query parsing has a cost.
252+ if strings .HasPrefix (queryString , "SELECT" ) ||
253+ (strings .HasPrefix (queryString , "WITH" ) &&
254+ strings .Contains (queryString , "SELECT" )) {
256255 return
257256 }
258257
You can’t perform that action at this time.
0 commit comments