This commit is contained in:
Jeff Mitchell
2016-08-19 16:48:32 -04:00
parent cb106531db
commit 357ecb4dfe
16 changed files with 35 additions and 37 deletions

View File

@@ -20,7 +20,7 @@ type PostgreSQLBackend struct {
get_query string
delete_query string
list_query string
logger *log.Logger
logger *log.Logger
}
// newPostgreSQLBackend constructs a PostgreSQL backend using the given
@@ -69,9 +69,9 @@ func newPostgreSQLBackend(conf map[string]string, logger *log.Logger) (Backend,
put_query: put_query,
get_query: "SELECT value FROM " + quoted_table + " WHERE path = $1 AND key = $2",
delete_query: "DELETE FROM " + quoted_table + " WHERE path = $1 AND key = $2",
list_query: "SELECT key FROM " + quoted_table + " WHERE path = $1" +
list_query: "SELECT key FROM " + quoted_table + " WHERE path = $1" +
"UNION SELECT substr(path, length($1)+1) FROM " + quoted_table + "WHERE parent_path = $1",
logger: logger,
logger: logger,
}
return m, nil
@@ -154,7 +154,7 @@ func (m *PostgreSQLBackend) Delete(fullPath string) error {
func (m *PostgreSQLBackend) List(prefix string) ([]string, error) {
defer metrics.MeasureSince([]string{"postgres", "list"}, time.Now())
rows, err := m.client.Query(m.list_query, "/" + prefix)
rows, err := m.client.Query(m.list_query, "/"+prefix)
if err != nil {
return nil, err
}