Use count(*) instead of column name.

This commit is contained in:
voussoir 2022-11-06 22:47:23 -08:00
parent bd4c997780
commit ca3766ea1b
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
2 changed files with 7 additions and 7 deletions

View file

@ -691,7 +691,7 @@ class Album(ObjectBase, GroupableMixin):
return sum(1 for child in walker) return sum(1 for child in walker)
query = stringtools.collapse_whitespace(''' query = stringtools.collapse_whitespace('''
SELECT COUNT(memberid) SELECT COUNT(*)
FROM album_group_rel FROM album_group_rel
WHERE parentid == ? WHERE parentid == ?
''') ''')
@ -707,7 +707,7 @@ class Album(ObjectBase, GroupableMixin):
performs the counting in the database instead of creating Photo objects. performs the counting in the database instead of creating Photo objects.
''' '''
query = stringtools.collapse_whitespace(''' query = stringtools.collapse_whitespace('''
SELECT COUNT(photoid) SELECT COUNT(*)
FROM album_photo_rel FROM album_photo_rel
WHERE albumid IN {albumids} WHERE albumid IN {albumids}
''') ''')

View file

@ -42,7 +42,7 @@ class PDBAlbumMixin:
return self.get_object_by_id(objects.Album, id) return self.get_object_by_id(objects.Album, id)
def get_album_count(self) -> int: def get_album_count(self) -> int:
return self.select_one_value('SELECT COUNT(id) FROM albums') return self.select_one_value('SELECT COUNT(*) FROM albums')
def get_albums(self) -> typing.Iterable[objects.Album]: def get_albums(self) -> typing.Iterable[objects.Album]:
return self.get_objects(objects.Album) return self.get_objects(objects.Album)
@ -178,7 +178,7 @@ class PDBBookmarkMixin:
return self.get_object_by_id(objects.Bookmark, id) return self.get_object_by_id(objects.Bookmark, id)
def get_bookmark_count(self) -> int: def get_bookmark_count(self) -> int:
return self.select_one_value('SELECT COUNT(id) FROM bookmarks') return self.select_one_value('SELECT COUNT(*) FROM bookmarks')
def get_bookmarks(self) -> typing.Iterable[objects.Bookmark]: def get_bookmarks(self) -> typing.Iterable[objects.Bookmark]:
return self.get_objects(objects.Bookmark) return self.get_objects(objects.Bookmark)
@ -268,7 +268,7 @@ class PDBPhotoMixin:
return photo return photo
def get_photo_count(self) -> int: def get_photo_count(self) -> int:
return self.select_one_value('SELECT COUNT(id) FROM photos') return self.select_one_value('SELECT COUNT(*) FROM photos')
def get_photos(self) -> typing.Iterable[objects.Photo]: def get_photos(self) -> typing.Iterable[objects.Photo]:
return self.get_objects(objects.Photo) return self.get_objects(objects.Photo)
@ -956,7 +956,7 @@ class PDBTagMixin:
return tag return tag
def get_tag_count(self) -> int: def get_tag_count(self) -> int:
return self.select_one_value('SELECT COUNT(id) FROM tags') return self.select_one_value('SELECT COUNT(*) FROM tags')
def get_tags(self) -> typing.Iterable[objects.Tag]: def get_tags(self) -> typing.Iterable[objects.Tag]:
''' '''
@ -1076,7 +1076,7 @@ class PDBUserMixin:
return self.get_cached_instance(objects.User, user_row) return self.get_cached_instance(objects.User, user_row)
def get_user_count(self) -> int: def get_user_count(self) -> int:
return self.select_one_value('SELECT COUNT(id) FROM users') return self.select_one_value('SELECT COUNT(*) FROM users')
def get_user_id_or_none(self, user_obj_or_id) -> typing.Optional[str]: def get_user_id_or_none(self, user_obj_or_id) -> typing.Optional[str]:
''' '''