diff --git a/CHANGES.rst b/CHANGES.rst index 0f0b841e..ba7ec744 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,12 @@ Changes ------- +0.31.2 +~~~~~~ + +- Now that usage patterns have formed, a new (final) API of the pg_collkey support has been settled on. + + 0.31.1 ~~~~~~ diff --git a/clld/__init__.py b/clld/__init__.py index bfd5134b..d5339221 100644 --- a/clld/__init__.py +++ b/clld/__init__.py @@ -5,7 +5,7 @@ from clld import interfaces -__version__ = "0.31.1" +__version__ = "0.31.2" class Resource(namedtuple('Resource', 'name model interface with_index with_rdfdump')): diff --git a/clld/db/util.py b/clld/db/util.py index 885c10c0..442b873a 100644 --- a/clld/db/util.py +++ b/clld/db/util.py @@ -3,12 +3,13 @@ import time import re -from sqlalchemy import Integer +from sqlalchemy import Integer, event from sqlalchemy.orm import joinedload +from sqlalchemy.schema import DDL from sqlalchemy.sql.expression import cast, func import transaction -from clld.db.meta import DBSession +from clld.db.meta import DBSession, Base from clld.db.models import common @@ -16,12 +17,24 @@ def as_int(col): return cast(col, Integer) -COLLKEY_SQL = """ +def with_collkey_ddl(): # pragma: no cover + """Register creation of collkey function. + + Can be called at module level in db initialization scripts to create the collkey + function. Once a session is bound to an engine collkey can be used to create indexes + or in order_by clauses, e.g.:: + + Index('ducet', collkey(common.Value.name)).create(DBSession.bind) + """ + event.listen( + Base.metadata, + 'before_create', + DDL(""" CREATE OR REPLACE FUNCTION collkey (text, text, bool, int4, bool) RETURNS bytea LANGUAGE 'c' IMMUTABLE STRICT AS '$libdir/collkey_icu.so', 'pgsqlext_collkey'; -""" +""").execute_if(dialect='postgresql')) def collkey(col, locale='root', special_at_4=True, level=4, numeric_sorting=False): diff --git a/docs/conf.py b/docs/conf.py index b71cf9a3..ab2eaebb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,10 +51,10 @@ # built documents. # # The full version, including alpha/beta/rc tags. -release = '0.31.1' +release = '0.31.2' # The short X.Y version. -version = '0.31.1' +version = '0.31.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index 6985e4c0..fed7c85a 100644 --- a/setup.py +++ b/setup.py @@ -80,7 +80,7 @@ ] setup(name='clld', - version='0.31.1', + version='0.31.2', description=( 'Python library supporting the development of cross-linguistic databases'), long_description=README + '\n\n' + CHANGES,