Project

General

Profile

0001-sql-add-user-name-to-fulltext-index-13524.patch

Frédéric Péters, 17 October 2016 03:39 PM

Download (1.8 KB)

View differences:

Subject: [PATCH] sql: add user name to fulltext index (#13524)

 tests/test_sql.py | 10 ++++++++++
 wcs/sql.py        |  3 +++
 2 files changed, 13 insertions(+)
tests/test_sql.py
33 33
    cleanup()
34 34

  
35 35
    pub = create_temporary_pub()
36
    pub.user_class = sql.SqlUser
36 37
    pub.is_using_postgresql = lambda: True
37 38

  
38 39
    conn = psycopg2.connect(user=os.environ['USER'])
......
858 859

  
859 860
    assert [x.id for x in data_class.select([st.FtsMatch('BAR')], order_by='id')] == range(21, 51)
860 861

  
862
    assert data_class.count([st.FtsMatch('Pierre')]) == 0
863
    sql.SqlUser.wipe()
864
    user = sql.SqlUser()
865
    user.name = 'Pierre'
866
    user.store()
867
    t.user_id = user.id
868
    t.store()
869
    assert data_class.count([st.FtsMatch('Pierre')]) == 1
870

  
861 871
def table_exists(cur, table_name):
862 872
    cur.execute('''SELECT COUNT(*) FROM information_schema.tables
863 873
                    WHERE table_name = %s''', (table_name,))
wcs/sql.py
1246 1246
            for evo in self._evolution:
1247 1247
                if evo.comment:
1248 1248
                    fts_strings.append(evo.comment)
1249
        user = self.get_user()
1250
        if user:
1251
            fts_strings.append(user.get_display_name())
1249 1252

  
1250 1253
        sql_statement = '''UPDATE %s SET fts = to_tsvector( %%(fts)s)
1251 1254
                            WHERE id = %%(id)s''' % self._table_name
1252
-