db: use literals for literals

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/653/head
Varun Patil 2023-04-24 22:07:58 -07:00
parent 34dc2263da
commit a0f347806d
10 changed files with 17 additions and 17 deletions

View File

@ -253,12 +253,12 @@ class FaceRecognitionBackend extends Backend
// By default hides individual faces when they have no name.
if (!$show_singles) {
$query->having($query->expr()->gt($count, $query->createNamedParameter(1)));
$query->having($query->expr()->gt($count, $query->expr()->literal(1, \PDO::PARAM_INT)));
}
// By default it shows the people who were not hidden
if (!$show_hidden) {
$query->andWhere($query->expr()->eq('frp.is_visible', $query->createNamedParameter(true)));
$query->andWhere($query->expr()->eq('frp.is_visible', $query->expr()->literal(true, \PDO::PARAM_BOOL)));
}
// ORDER by number of faces in cluster and id for response stability.

View File

@ -72,7 +72,7 @@ class PlacesBackend extends Backend
$query->select('e.osm_id', $count)->from('memories_planet', 'e');
// WHERE these are not special clusters (e.g. timezone)
$query->where($query->expr()->gt('e.admin_level', $query->createNamedParameter(0, \PDO::PARAM_INT)));
$query->where($query->expr()->gt('e.admin_level', $query->expr()->literal(0, \PDO::PARAM_INT)));
// WHERE there are items with this osm_id
$query->innerJoin('e', 'memories_places', 'mp', $query->expr()->eq('mp.osm_id', 'e.osm_id'));

View File

@ -61,7 +61,7 @@ class TagsBackend extends Backend
$tagId = $this->getSystemTagId($query, $tagName);
$query->innerJoin('m', 'systemtag_object_mapping', 'stom', $query->expr()->andX(
$query->expr()->eq('stom.objecttype', $query->createNamedParameter('files')),
$query->expr()->eq('stom.objecttype', $query->expr()->literal('files')),
$query->expr()->eq('stom.objectid', 'm.objectid'),
$query->expr()->eq('stom.systemtagid', $query->createNamedParameter($tagId)),
));
@ -74,12 +74,12 @@ class TagsBackend extends Backend
// SELECT visible tag name and count of photos
$count = $query->func()->count($query->createFunction('DISTINCT m.fileid'), 'count');
$query->select('st.id', 'st.name', $count)->from('systemtag', 'st')->where(
$query->expr()->eq('visibility', $query->createNamedParameter(1)),
$query->expr()->eq('visibility', $query->expr()->literal(1, \PDO::PARAM_INT)),
);
// WHERE there are items with this tag
$query->innerJoin('st', 'systemtag_object_mapping', 'stom', $query->expr()->andX(
$query->expr()->eq('stom.objecttype', $query->createNamedParameter('files')),
$query->expr()->eq('stom.objecttype', $query->expr()->literal('files')),
$query->expr()->eq('stom.systemtagid', 'st.id'),
));
@ -121,7 +121,7 @@ class TagsBackend extends Backend
'systemtag_object_mapping',
'stom'
)->where(
$query->expr()->eq('stom.objecttype', $query->createNamedParameter('files')),
$query->expr()->eq('stom.objecttype', $query->expr()->literal('files')),
$query->expr()->eq('stom.systemtagid', $query->createNamedParameter($tagId)),
);
@ -147,7 +147,7 @@ class TagsBackend extends Backend
$res = $sqb->select('id')->from('systemtag')->where(
$sqb->expr()->andX(
$sqb->expr()->eq('name', $sqb->createNamedParameter($tagName)),
$sqb->expr()->eq('visibility', $sqb->createNamedParameter(1)),
$sqb->expr()->eq('visibility', $sqb->expr()->literal(1, \PDO::PARAM_INT)),
)
)->executeQuery()->fetchOne();

View File

@ -198,7 +198,7 @@ class AlbumsQuery
->innerJoin('pa', $this->collaboratorsTable(), 'pc', $query->expr()->andX(
$query->expr()->eq('pc.album_id', 'pa.album_id'),
$query->expr()->eq('collaborator_id', $query->createNamedParameter($token)),
$query->expr()->eq('collaborator_type', $query->createNamedParameter(3)), // = TYPE_LINK
$query->expr()->eq('collaborator_type', $query->expr()->literal(3, \PDO::PARAM_INT)), // = TYPE_LINK
))
;

View File

@ -33,7 +33,7 @@ trait TimelineQueryFilters
public function transformVideoFilter(IQueryBuilder &$query, bool $aggregate)
{
$query->andWhere($query->expr()->eq('m.isvideo', $query->createNamedParameter('1')));
$query->andWhere($query->expr()->eq('m.isvideo', $query->expr()->literal(true, \PDO::PARAM_BOOL)));
}
public function transformLimit(IQueryBuilder &$query, bool $aggregate, int $limit)
@ -59,9 +59,9 @@ trait TimelineQueryFilters
return $query->createFunction(
$query->getConnection()->getQueryBuilder()->select('id')->from('vcategory', 'vc')->where(
$query->expr()->andX(
$query->expr()->eq('type', $query->createNamedParameter('files')),
$query->expr()->eq('type', $query->expr()->literal('files')),
$query->expr()->eq('uid', $query->createNamedParameter(Util::getUID())),
$query->expr()->eq('category', $query->createNamedParameter(ITags::TAG_FAVORITE)),
$query->expr()->eq('category', $query->expr()->literal(ITags::TAG_FAVORITE)),
)
)->getSQL()
);

View File

@ -88,7 +88,7 @@ trait TimelineQuerySingleItem
->from('memories_places', 'mp')
->innerJoin('mp', 'memories_planet', 'e', $qb->expr()->eq('mp.osm_id', 'e.osm_id'))
->where($qb->expr()->eq('mp.fileid', $qb->createNamedParameter($id, \PDO::PARAM_INT)))
->andWhere($qb->expr()->gt('e.admin_level', $qb->createNamedParameter(0, \PDO::PARAM_INT)))
->andWhere($qb->expr()->gt('e.admin_level', $qb->expr()->literal(0, \PDO::PARAM_INT)))
->orderBy('e.admin_level', 'DESC')
;

View File

@ -122,7 +122,7 @@ trait TimelineWriteMap
$query = $this->connection->getQueryBuilder();
$query->insert('memories_mapclusters')
->values([
'point_count' => $query->createNamedParameter(1, IQueryBuilder::PARAM_INT),
'point_count' => $query->expr()->literal(1, IQueryBuilder::PARAM_INT),
'lat_sum' => $query->createNamedParameter($lat, IQueryBuilder::PARAM_STR),
'lon_sum' => $query->createNamedParameter($lon, IQueryBuilder::PARAM_STR),
])

View File

@ -80,7 +80,7 @@ trait TimelineWriteOrphans
$query = $this->connection->getQueryBuilder();
$query->select(...$fields)
->from('memories')
->where($query->expr()->eq('orphan', $query->createNamedParameter(true, IQueryBuilder::PARAM_BOOL)))
->where($query->expr()->eq('orphan', $query->expr()->literal(true, IQueryBuilder::PARAM_BOOL)))
->setMaxResults($count)
;

View File

@ -158,7 +158,7 @@ trait TimelineWritePlaces
$query->select('name')
->from('memories_planet')
->where($query->expr()->in('osm_id', $query->createNamedParameter($osmIds, IQueryBuilder::PARAM_INT_ARRAY)))
->andWhere($query->expr()->eq('admin_level', $query->createNamedParameter(-7, IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->eq('admin_level', $query->expr()->literal(-7, IQueryBuilder::PARAM_INT)))
;
// Get name of timezone

View File

@ -155,7 +155,7 @@ class Index
$query->leftJoin('f', $table, $alias, $query->expr()->andX(
$query->expr()->eq('f.fileid', "{$alias}.fileid"),
$query->expr()->eq('f.mtime', "{$alias}.mtime"),
$query->expr()->eq("{$alias}.orphan", $query->createNamedParameter(false, IQueryBuilder::PARAM_BOOL))
$query->expr()->eq("{$alias}.orphan", $query->expr()->literal(false, IQueryBuilder::PARAM_BOOL))
));
$query->andWhere($query->expr()->isNull("{$alias}.fileid"));