Local queries (#641)
* Read local queries from pgweb home directory * Refactor local query functionality * Allow picking local query in the query tab * WIP * Disable local query dropdown during execution * Only allow local queries running in a single session mode * Add middleware to enforce local query endpoint availability * Fix query check * Add query store tests * Make query store errors portable * Skip building specific tests on windows
This commit is contained in:
23
pkg/queries/query.go
Normal file
23
pkg/queries/query.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package queries
|
||||
|
||||
type Query struct {
|
||||
ID string
|
||||
Path string
|
||||
Meta *Metadata
|
||||
Data string
|
||||
}
|
||||
|
||||
// IsPermitted returns true if a query is allowed to execute for a given db context
|
||||
func (q Query) IsPermitted(host, user, database, mode string) bool {
|
||||
// All fields must be provided for matching
|
||||
if q.Meta == nil || host == "" || user == "" || database == "" || mode == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
meta := q.Meta
|
||||
|
||||
return meta.Host.matches(host) &&
|
||||
meta.User.matches(user) &&
|
||||
meta.Database.matches(database) &&
|
||||
meta.Mode.matches(mode)
|
||||
}
|
||||
Reference in New Issue
Block a user