Permalink
Browse files

Create table lazily if not exists

  • Loading branch information...
1 parent 2c1b550 commit f175e595db88ff75b1e1bd5e8fb9cb0ffa8966be @beberlei beberlei committed Apr 8, 2013
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php
View
12 lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php
@@ -79,10 +79,14 @@ public function insert($storageName, $key, array $data)
try {
$this->client->insertEntity($storageName, $entity);
} catch(ServiceException $e){
- throw new StorageException(
- "Could not save entity in table, WindowsAzure SDK client reported error: " . $e->getMessage(),
- $e->getCode(), $e
- );
+ if ($e->getCode() == 404) {
+ $this->client->createTable($storageName);
+ } else {
+ throw new StorageException(
+ "Could not save entity in table, WindowsAzure SDK client reported error: " . $e->getMessage(),
+ $e->getCode(), $e
+ );
+ }
}
}

0 comments on commit f175e59

Please sign in to comment.