Require voussoirkit 0.0.28 for sqlhelpers.listify.

Instead of defining that within etiquette.
This commit is contained in:
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('.') tagname = tagname.strip('.')
return (tagname, synonym, rename_to) 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): def truthystring(s):
''' '''
If s is already a boolean, int, or None, return a boolean or None. 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 bytestring
from voussoirkit import pathclass from voussoirkit import pathclass
from voussoirkit import spinal from voussoirkit import spinal
from voussoirkit import sqlhelpers
from . import constants from . import constants
from . import decorators from . import decorators
@ -517,7 +518,7 @@ class Album(ObjectBase, GroupableMixin):
else: else:
albumids = [self.id] albumids = [self.id]
albumids = helpers.sql_listify(albumids) albumids = sqlhelpers.listify(albumids)
query = query.format(albumids=albumids) query = query.format(albumids=albumids)
total = self.photodb.sql_select_one(query)[0] total = self.photodb.sql_select_one(query)[0]
return total return total
@ -538,7 +539,7 @@ class Album(ObjectBase, GroupableMixin):
else: else:
albumids = [self.id] albumids = [self.id]
albumids = helpers.sql_listify(albumids) albumids = sqlhelpers.listify(albumids)
query = query.format(albumids=albumids) query = query.format(albumids=albumids)
total = self.photodb.sql_select_one(query)[0] total = self.photodb.sql_select_one(query)[0]
return total return total
@ -886,7 +887,7 @@ class Photo(ObjectBase):
tag_options = [tag] tag_options = [tag]
tag_by_id = {t.id: t for t in tag_options} 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( rel_row = self.photodb.sql_select_one(
f'SELECT tagid FROM photo_tag_rel WHERE photoid == ? AND tagid IN {tag_option_ids}', f'SELECT tagid FROM photo_tag_rel WHERE photoid == ? AND tagid IN {tag_option_ids}',
[self.id] [self.id]
@ -1293,7 +1294,7 @@ class Tag(ObjectBase, GroupableMixin):
UPDATE photo_tag_rel UPDATE photo_tag_rel
SET tagid = ? SET tagid = ?
WHERE tagid == ? WHERE tagid == ?
AND photoid IN {helpers.sql_listify(replace_photoids)} AND photoid IN {sqlhelpers.listify(replace_photoids)}
''' '''
bindings = [mastertag.id, self.id] bindings = [mastertag.id, self.id]
self.photodb.sql_execute(query, bindings) self.photodb.sql_execute(query, bindings)

View file

@ -566,7 +566,7 @@ class PDBPhotoMixin:
if author: if author:
author_ids = [user.id for user in 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 extension:
if '*' in extension: if '*' in extension:

View file

@ -9,6 +9,7 @@ from . import helpers
from . import objects from . import objects
from voussoirkit import expressionmatch from voussoirkit import expressionmatch
from voussoirkit import sqlhelpers
def expand_mmf(tag_musts, tag_mays, tag_forbids): 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.append( ('NOT EXISTS', tag_forbids) )
clauses = [ 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 for (operator, tagset) in clauses
] ]
clauses = [ clauses = [

View file

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