0001-sql-add-user-name-to-fulltext-index-13524.patch
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 |
... | ... | |
1824 | 1827 |
return result |
1825 | 1828 | |
1826 | 1829 | |
1827 |
SQL_LEVEL = 17
|
|
1830 |
SQL_LEVEL = 18
|
|
1828 | 1831 | |
1829 | 1832 |
def migrate_global_views(conn, cur): |
1830 | 1833 |
cur.execute('''SELECT COUNT(*) FROM information_schema.tables |
... | ... | |
1886 | 1889 |
# 12: (second part), store fts in existing rows |
1887 | 1890 |
for user_id in SqlUser.keys(): |
1888 | 1891 |
SqlUser.get(user_id).store() |
1889 |
if sql_level < 17:
|
|
1892 |
if sql_level < 18:
|
|
1890 | 1893 |
# 17: store last_update_time in tables |
1894 |
# 18: add user name to full-text search index |
|
1891 | 1895 |
# load and store all formdatas |
1892 | 1896 |
from wcs.formdef import FormDef |
1893 | 1897 |
for formdef in FormDef.select(): |
1894 |
- |