Require voussoirkit 0.0.28 for sqlhelpers.listify.

Instead of defining that within etiquette.
master
voussoir 2019-01-01 18:08:47 -08:00
parent c8f7239e19
commit d66dc53215
5 changed files with 9 additions and 16 deletions

View File

@ -482,15 +482,6 @@ def split_easybake_string(ebstring):
tagname = tagname.strip('.')
return (tagname, synonym, rename_to)
def sql_listify(items):
'''
Given a list of strings, return a string in the form of an SQL list.
['hi', 'ho', 'hey'] -> '("hi", "ho", "hey")'
'''
items = ', '.join(f'"{item}"' for item in items)
return '(%s)' % items
def truthystring(s):
'''
If s is already a boolean, int, or None, return a boolean or None.

View File

@ -10,6 +10,7 @@ import traceback
from voussoirkit import bytestring
from voussoirkit import pathclass
from voussoirkit import spinal
from voussoirkit import sqlhelpers
from . import constants
from . import decorators
@ -517,7 +518,7 @@ class Album(ObjectBase, GroupableMixin):
else:
albumids = [self.id]
albumids = helpers.sql_listify(albumids)
albumids = sqlhelpers.listify(albumids)
query = query.format(albumids=albumids)
total = self.photodb.sql_select_one(query)[0]
return total
@ -538,7 +539,7 @@ class Album(ObjectBase, GroupableMixin):
else:
albumids = [self.id]
albumids = helpers.sql_listify(albumids)
albumids = sqlhelpers.listify(albumids)
query = query.format(albumids=albumids)
total = self.photodb.sql_select_one(query)[0]
return total
@ -886,7 +887,7 @@ class Photo(ObjectBase):
tag_options = [tag]
tag_by_id = {t.id: t for t in tag_options}
tag_option_ids = helpers.sql_listify(tag_by_id)
tag_option_ids = sqlhelpers.listify(tag_by_id)
rel_row = self.photodb.sql_select_one(
f'SELECT tagid FROM photo_tag_rel WHERE photoid == ? AND tagid IN {tag_option_ids}',
[self.id]
@ -1293,7 +1294,7 @@ class Tag(ObjectBase, GroupableMixin):
UPDATE photo_tag_rel
SET tagid = ?
WHERE tagid == ?
AND photoid IN {helpers.sql_listify(replace_photoids)}
AND photoid IN {sqlhelpers.listify(replace_photoids)}
'''
bindings = [mastertag.id, self.id]
self.photodb.sql_execute(query, bindings)

View File

@ -566,7 +566,7 @@ class PDBPhotoMixin:
if author:
author_ids = [user.id for user in author]
wheres.append('author_id IN %s' % helpers.sql_listify(author_ids))
wheres.append(f'author_id IN {sqlhelpers.listify(author_ids)}')
if extension:
if '*' in extension:

View File

@ -9,6 +9,7 @@ from . import helpers
from . import objects
from voussoirkit import expressionmatch
from voussoirkit import sqlhelpers
def expand_mmf(tag_musts, tag_mays, tag_forbids):
@ -389,7 +390,7 @@ def photo_tag_rel_exist_clauses(tag_musts, tag_mays, tag_forbids):
clauses.append( ('NOT EXISTS', tag_forbids) )
clauses = [
(operator, helpers.sql_listify(tag.id for tag in tagset))
(operator, sqlhelpers.listify(tag.id for tag in tagset))
for (operator, tagset) in clauses
]
clauses = [

View File

@ -15,4 +15,4 @@ git+https://github.com/senko/python-video-converter.git
zipstream
# My own variety toolkit.
voussoirkit>=0.0.25
voussoirkit>=0.0.28