Merge John Ralls's 'bug12343' into maintenance/gramps51.

This commit is contained in:
John Ralls 2021-07-03 06:54:09 -07:00
commit c177c13f99
2 changed files with 9 additions and 28 deletions

View File

@ -364,12 +364,9 @@ class DBAPI(DbGeneric):
:type locale: A GrampsLocale object. :type locale: A GrampsLocale object.
""" """
if sort_handles: if sort_handles:
if locale != glocale:
self.dbapi.check_collation(locale)
self.dbapi.execute('SELECT handle FROM person ' self.dbapi.execute('SELECT handle FROM person '
'ORDER BY surname ' 'ORDER BY surname '
'COLLATE "%s"' % locale.get_collation()) 'COLLATE "%s"' % self.dbapi.check_collation(locale))
else: else:
self.dbapi.execute("SELECT handle FROM person") self.dbapi.execute("SELECT handle FROM person")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
@ -386,9 +383,6 @@ class DBAPI(DbGeneric):
:type locale: A GrampsLocale object. :type locale: A GrampsLocale object.
""" """
if sort_handles: if sort_handles:
if locale != glocale:
self.dbapi.check_collation(locale)
sql = ('SELECT family.handle ' + sql = ('SELECT family.handle ' +
'FROM family ' + 'FROM family ' +
'LEFT JOIN person AS father ' + 'LEFT JOIN person AS father ' +
@ -403,7 +397,7 @@ class DBAPI(DbGeneric):
'THEN mother.given_name ' + 'THEN mother.given_name ' +
'ELSE father.given_name ' + 'ELSE father.given_name ' +
'END) ' + 'END) ' +
'COLLATE "%s"' % locale.get_collation()) 'COLLATE "%s"' % self.dbapi.check_collation(locale))
self.dbapi.execute(sql) self.dbapi.execute(sql)
else: else:
self.dbapi.execute("SELECT handle FROM family") self.dbapi.execute("SELECT handle FROM family")
@ -430,12 +424,9 @@ class DBAPI(DbGeneric):
:type locale: A GrampsLocale object. :type locale: A GrampsLocale object.
""" """
if sort_handles: if sort_handles:
if locale != glocale:
self.dbapi.check_collation(locale)
self.dbapi.execute('SELECT handle FROM citation ' self.dbapi.execute('SELECT handle FROM citation '
'ORDER BY page ' 'ORDER BY page '
'COLLATE "%s"' % locale.get_collation()) 'COLLATE "%s"' % self.dbapi.check_collation(locale))
else: else:
self.dbapi.execute("SELECT handle FROM citation") self.dbapi.execute("SELECT handle FROM citation")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
@ -452,12 +443,9 @@ class DBAPI(DbGeneric):
:type locale: A GrampsLocale object. :type locale: A GrampsLocale object.
""" """
if sort_handles: if sort_handles:
if locale != glocale:
self.dbapi.check_collation(locale)
self.dbapi.execute('SELECT handle FROM source ' self.dbapi.execute('SELECT handle FROM source '
'ORDER BY title ' 'ORDER BY title '
'COLLATE "%s"' % locale.get_collation()) 'COLLATE "%s"' % self.dbapi.check_collation(locale))
else: else:
self.dbapi.execute("SELECT handle from source") self.dbapi.execute("SELECT handle from source")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
@ -474,12 +462,9 @@ class DBAPI(DbGeneric):
:type locale: A GrampsLocale object. :type locale: A GrampsLocale object.
""" """
if sort_handles: if sort_handles:
if locale != glocale:
self.dbapi.check_collation(locale)
self.dbapi.execute('SELECT handle FROM place ' self.dbapi.execute('SELECT handle FROM place '
'ORDER BY title ' 'ORDER BY title '
'COLLATE "%s"' % locale.get_collation()) 'COLLATE "%s"' % self.dbapi.check_collation(locale))
else: else:
self.dbapi.execute("SELECT handle FROM place") self.dbapi.execute("SELECT handle FROM place")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
@ -505,12 +490,9 @@ class DBAPI(DbGeneric):
:type locale: A GrampsLocale object. :type locale: A GrampsLocale object.
""" """
if sort_handles: if sort_handles:
if locale != glocale:
self.dbapi.check_collation(locale)
self.dbapi.execute('SELECT handle FROM media ' self.dbapi.execute('SELECT handle FROM media '
'ORDER BY desc ' 'ORDER BY desc '
'COLLATE "%s"' % locale.get_collation()) 'COLLATE "%s"' % self.dbapi.check_collation(locale))
else: else:
self.dbapi.execute("SELECT handle FROM media") self.dbapi.execute("SELECT handle FROM media")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()
@ -536,12 +518,9 @@ class DBAPI(DbGeneric):
:type locale: A GrampsLocale object. :type locale: A GrampsLocale object.
""" """
if sort_handles: if sort_handles:
if locale != glocale:
self.dbapi.check_collation(locale)
self.dbapi.execute('SELECT handle FROM tag ' self.dbapi.execute('SELECT handle FROM tag '
'ORDER BY name ' 'ORDER BY name '
'COLLATE "%s"' % locale.get_collation()) 'COLLATE "%s"' % self.dbapi.check_collation(locale))
else: else:
self.dbapi.execute("SELECT handle FROM tag") self.dbapi.execute("SELECT handle FROM tag")
rows = self.dbapi.fetchall() rows = self.dbapi.fetchall()

View File

@ -117,6 +117,8 @@ class Connection:
collation = locale.get_collation().translate(self.__tmap) collation = locale.get_collation().translate(self.__tmap)
if collation not in self.__collations: if collation not in self.__collations:
self.__connection.create_collation(collation, locale.strcoll) self.__connection.create_collation(collation, locale.strcoll)
self.__collations.append(collation)
return collation
def execute(self, *args, **kwargs): def execute(self, *args, **kwargs):
""" """