Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not allow empty database name, closes #1950 #1955

Merged
merged 2 commits into from
Mar 14, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
do not accept empty database name in drop
  • Loading branch information
dullgiulio committed Mar 14, 2015
commit 2cc2077c3d75937352bc2c67ea01a29b0f7d9210
4 changes: 0 additions & 4 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ func (db *database) UnmarshalJSON(data []byte) error {
return err
}

if o.Name == "" {
return ErrDatabaseNameRequired
}

// Copy over properties from intermediate type.
db.name = o.Name
db.defaultRetentionPolicy = o.DefaultRetentionPolicy
Expand Down
3 changes: 3 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,9 @@ func (s *Server) applyCreateDatabase(m *messaging.Message) (err error) {

// DropDatabase deletes an existing database.
func (s *Server) DropDatabase(name string) error {
if name == "" {
return ErrDatabaseNameRequired
}
c := &dropDatabaseCommand{Name: name}
_, err := s.broadcast(dropDatabaseMessageType, c)
return err
Expand Down
5 changes: 5 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ func TestServer_DropDatabase(t *testing.T) {
s := OpenServer(NewMessagingClient())
defer s.Close()

// Attempt creating empty name database.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: comment is not quite right.

if err := s.DropDatabase(""); err != influxdb.ErrDatabaseNameRequired {
t.Fatal("expected error on empty database name")
}

// Create the "foo" database and verify it exists.
if err := s.CreateDatabase("foo"); err != nil {
t.Fatal(err)
Expand Down