I was doing some testing and noticed that the create_database call makes two GET requests before the PUT to create a remote database.
This is what happens:
client.create_database() calls database.exists() which does a GET
If it didn't exist client.create_database() calls database.create()
database.create() calls exists() which does another GET
If the database does not exist then database.create() finally does the PUT.
I think it could be beneficial to replace these three round trips with a single request to PUT given that if the database already exists a 412 is returned.
There is some complication in that currently database.create() would not throw for the 412 response case, but client.create_database optionally needs to throw.
Cloudant (python-cloudant) version(s) that are affected by this issue.
I was doing some testing and noticed that the
create_database
call makes twoGET
requests before thePUT
to create a remote database. This is what happens:client.create_database()
callsdatabase.exists()
which does aGET
client.create_database()
callsdatabase.create()
database.create()
callsexists()
which does anotherGET
database.create()
finally does thePUT
.I think it could be beneficial to replace these three round trips with a single request to
PUT
given that if the database already exists a412
is returned. There is some complication in that currentlydatabase.create()
would not throw for the412
response case, butclient.create_database
optionally needs to throw.