Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .changelog/current/2882-deprecated-sql-execute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Maintenance

- Port away from deprecated execute method

50 changes: 25 additions & 25 deletions lib/Db/RecipeDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @deprecated
* @todo Why deprecated?

Check warning on line 36 in lib/Db/RecipeDb.php

View workflow job for this annotation

GitHub Actions / Check for added todo messages

Found @todo Why deprecated?
*/
public function findRecipeById(int $id) {
$qb = $this->db->getQueryBuilder();
Expand All @@ -43,7 +43,7 @@
->where('recipe_id = :id');
$qb->setParameter('id', $id, IQueryBuilder::PARAM_INT);

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$row = $cursor->fetch();
$cursor->closeCursor();

Expand All @@ -67,23 +67,23 @@
->where('recipe_id = :id');
$qb->setParameter('id', $id, IQueryBuilder::PARAM_INT);

$qb->execute();
$qb->executeStatement();

$qb = $this->db->getQueryBuilder();

$qb->delete(self::DB_TABLE_KEYWORDS)
->where('recipe_id = :id');
$qb->setParameter('id', $id, IQueryBuilder::PARAM_INT);

$qb->execute();
$qb->executeStatement();

$qb = $this->db->getQueryBuilder();

$qb->delete(self::DB_TABLE_CATEGORIES)
->where('recipe_id = :id');
$qb->setParameter('id', $id, IQueryBuilder::PARAM_INT);

$qb->execute();
$qb->executeStatement();
}

public function findAllRecipes(string $user_id) {
Expand All @@ -108,7 +108,7 @@
)
);

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetchAll();
$cursor->closeCursor();

Expand Down Expand Up @@ -173,7 +173,7 @@
->orderBy('k.name');
$qb->setParameter('user', $user_id, Types::STRING);

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetchAll();
$cursor->closeCursor();

Expand Down Expand Up @@ -202,7 +202,7 @@
->orderBy('c.name');
$qb->setParameter('user', $user_id, Types::STRING);

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetchAll();
$cursor->closeCursor();

Expand Down Expand Up @@ -230,7 +230,7 @@
$qb->expr()->isNull('c.name')
);

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$row = $cursor->fetch();
$cursor->closeCursor();

Expand Down Expand Up @@ -289,7 +289,7 @@
);
}

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetchAll();
$cursor->closeCursor();

Expand Down Expand Up @@ -333,7 +333,7 @@
$qb->groupBy(['r.name', 'r.recipe_id', 'kk.name', 'r.date_created', 'r.date_modified', 'c.name']);
$qb->orderBy('r.name');

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetchAll();
$cursor->closeCursor();

Expand Down Expand Up @@ -388,7 +388,7 @@
$qb->groupBy(['r.name', 'r.recipe_id', 'kk.name', 'r.date_created', 'r.date_modified', 'c.name']);
$qb->orderBy('r.name');

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetchAll();
$cursor->closeCursor();

Expand Down Expand Up @@ -430,23 +430,23 @@
->orWhere('user_id = :empty');
$qb->setParameter('user', $user_id, Types::STRING);
$qb->setParameter('empty', 'empty', Types::STRING);
$qb->execute();
$qb->executeStatement();

$qb = $this->db->getQueryBuilder();
$qb->delete(self::DB_TABLE_KEYWORDS)
->where('user_id = :user')
->orWhere('user_id = :empty');
$qb->setParameter('user', $user_id, Types::STRING);
$qb->setParameter('empty', 'empty', Types::STRING);
$qb->execute();
$qb->executeStatement();

$qb = $this->db->getQueryBuilder();
$qb->delete(self::DB_TABLE_CATEGORIES)
->where('user_id = :user')
->orWhere('user_id = :empty');
$qb->setParameter('user', $user_id, Types::STRING);
$qb->setParameter('empty', 'empty', Types::STRING);
$qb->execute();
$qb->executeStatement();
}

private function isRecipeEmpty($json) {
Expand Down Expand Up @@ -484,7 +484,7 @@
));
}

$qb->execute();
$qb->executeStatement();
}

/**
Expand Down Expand Up @@ -518,7 +518,7 @@
$dateModified = $this->parseDate($recipe['dateModified']);
$qb->setParameter('dateModified', $dateModified, Types::DATETIME);

$qb->execute();
$qb->executeStatement();
}
}

Expand All @@ -544,7 +544,7 @@
$qb->setParameter('uid', $userId);

try {
$qb->execute();
$qb->executeStatement();
} catch (\Exception $ex) {
throw $ex;
}
Expand All @@ -561,7 +561,7 @@
$qb->setParameter('rid', $recipeId);
$qb->setParameter('uid', $userId);

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetchAll();
$cursor->closeCursor();

Expand All @@ -583,7 +583,7 @@
$qb->setParameter('rid', $recipeId);
$qb->setParameter('uid', $userId);

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetch();
$cursor->closeCursor();

Expand All @@ -601,7 +601,7 @@
$qb->set('name', $qb->createNamedParameter($categoryName, IQueryBuilder::PARAM_STR));
$qb->setParameter('rid', $recipeId, Types::INTEGER);
$qb->setParameter('user', $userId, Types::STRING);
$qb->execute();
$qb->executeStatement();
}

public function addCategoryOfRecipe(int $recipeId, string $categoryName, string $userId) {
Expand All @@ -623,7 +623,7 @@
$qb->setParameter('user', $userId, Types::STRING);

try {
$qb->execute();
$qb->executeStatement();
} catch (\Exception $e) {
// Category didn't meet restrictions, skip it
}
Expand All @@ -635,7 +635,7 @@
->where('recipe_id = :rid', 'user_id = :user');
$qb->setParameter('rid', $recipeId, Types::INTEGER);
$qb->setParameter('user', $userId, Types::STRING);
$qb->execute();
$qb->executeStatement();
}

public function addKeywordPairs(array $pairs, string $userId) {
Expand All @@ -653,9 +653,9 @@
$qb->setParameter('name', $p['name'], Types::STRING);

try {
$qb->execute();
$qb->executeStatement();
} catch (\Exception $ex) {
// The insertion of a keywaord might conflict with the requirements. Skip it.
// The insertion of a keyword might conflict with the requirements. Skip it.
}
}
}
Expand All @@ -678,7 +678,7 @@
);
}

$qb->execute();
$qb->executeStatement();
}

private function parseDate(?string $date) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Migration/Version000000Date20210701093123.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array
->having('COUNT(*) > 1');
//echo $qb->getSQL() . "\n";

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetchAll();

if (sizeof($result) > 0) {
Expand Down Expand Up @@ -66,10 +66,10 @@ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array
foreach ($result as $r) {
$qb->setParameter('user', $r['user']);
$qb->setParameter('recipe', $r['recipe']);
$qb->execute();
$qb->executeStatement();

$qb2->setParameter('user', $r['user']);
$qb2->execute();
$qb2->executeStatement();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private function resetSQLite(): void {
$qb = $this->db->getQueryBuilder();
$qb->delete('migrations')->where('app = :app');
$qb->setParameter('app', 'cookbook');
$qb->execute();
$qb->executeStatement();

$this->schema->performDropTableCalls();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testRedundantEntriesInDB($data, $updatedUsers) {
$qb->setParameter('user', $d[0]);
$qb->setParameter('recipe', $d[1]);

$this->assertEquals(1, $qb->execute());
$this->assertEquals(1, $qb->executeStatement());
}

// Initialize configuration values to track reindex timestamps
Expand All @@ -52,7 +52,7 @@ public function testRedundantEntriesInDB($data, $updatedUsers) {
}, $data));
foreach ($users as $u) {
$qb->setParameter('user', $u);
$this->assertEquals(1, $qb->execute());
$this->assertEquals(1, $qb->executeStatement());
}

// Run the migration under test
Expand All @@ -69,7 +69,7 @@ public function testRedundantEntriesInDB($data, $updatedUsers) {
$qb->setParameter('appid', 'cookbook');
$qb->setParameter('property', 'last_index_update');

$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$result = $cursor->fetchAll();

// Filter those entries from the configuration that were marked as to be reindexed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testRedundantEntriesInDB(/*$data, $updatedUsers*/) {
$qb->setParameter('user', 'username');
$qb->setParameter('recipe', 1234);

$this->assertEquals(1, $qb->execute());
$this->assertEquals(1, $qb->executeStatement());

$table = $this->schema->getTable('cookbook_names');
$this->assertFalse($table->hasColumn('date_created'));
Expand All @@ -41,7 +41,7 @@ public function testRedundantEntriesInDB(/*$data, $updatedUsers*/) {

$qb = $this->db->getQueryBuilder();
$qb->select('date_created', 'date_modified')->from('cookbook_names');
$res = $qb->execute();
$res = $qb->executeQuery();
$data = $res->fetchAll();

$this->assertEquals(1, count($data));
Expand Down
Loading