Skip to content

Commit 7fd7267

Browse files
committed
Allow passing an empty apikey, improve error message for deletion failure
1 parent 4a4f54b commit 7fd7267

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

dbhub.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ func (c Connection) Delete(dbName string) (err error) {
9696
// Delete the database
9797
queryUrl := c.Server + "/v1/delete"
9898
err = sendRequestJSON(queryUrl, data, nil)
99+
if err != nil && err.Error() == "no rows in result set" { // Feels like a dodgy workaround
100+
err = fmt.Errorf("Unknown database\n")
101+
}
99102
return
100103
}
101104

@@ -191,7 +194,9 @@ func (c Connection) Metadata(dbOwner, dbName string) (meta com.MetadataResponseC
191194
func (c Connection) PrepareVals(dbOwner, dbName string, ident Identifier) (data url.Values) {
192195
// Prepare the API parameters
193196
data = url.Values{}
194-
data.Set("apikey", c.APIKey)
197+
if c.APIKey != "" {
198+
data.Set("apikey", c.APIKey)
199+
}
195200
if dbOwner != "" {
196201
data.Set("dbowner", dbOwner)
197202
}

0 commit comments

Comments
 (0)