From 0c1cf43519d1e3cf9555c6c62e222a39b3febaec Mon Sep 17 00:00:00 2001 From: Stu Tomlinson Date: Sat, 21 Jan 2023 14:22:52 +0000 Subject: [PATCH] Fix a long standing bug in new schema migration ... and make the test that uncovered it explicitly fail (there was already a TODO) instead of passing but with errors logged --- sql/pg.new.sql | 2 +- src/mod_admin_update_sql.erl | 2 +- test/vcard_tests.erl | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sql/pg.new.sql b/sql/pg.new.sql index ba0dc31dd..6a13ad6f3 100644 --- a/sql/pg.new.sql +++ b/sql/pg.new.sql @@ -92,7 +92,7 @@ -- DROP INDEX i_vcard_search_lemail; -- DROP INDEX i_vcard_search_lorgname; -- DROP INDEX i_vcard_search_lorgunit; --- ALTER TABLE vcard_search ADD PRIMARY KEY (server_host, username); +-- ALTER TABLE vcard_search ADD PRIMARY KEY (server_host, lusername); -- CREATE INDEX i_vcard_search_sh_lfn ON vcard_search(server_host, lfn); -- CREATE INDEX i_vcard_search_sh_lfamily ON vcard_search(server_host, lfamily); -- CREATE INDEX i_vcard_search_sh_lgiven ON vcard_search(server_host, lgiven); diff --git a/src/mod_admin_update_sql.erl b/src/mod_admin_update_sql.erl index 4bc9561c7..db7730e95 100644 --- a/src/mod_admin_update_sql.erl +++ b/src/mod_admin_update_sql.erl @@ -246,7 +246,7 @@ update_tables(State) -> drop_index(State, "vcard_search", "i_vcard_search_lemail"), drop_index(State, "vcard_search", "i_vcard_search_lorgname"), drop_index(State, "vcard_search", "i_vcard_search_lorgunit"), - add_pkey(State, "vcard_search", ["server_host", "username"]), + add_pkey(State, "vcard_search", ["server_host", "lusername"]), create_index(State, "vcard_search", "i_vcard_search_sh_lfn", ["server_host", "lfn"]), create_index(State, "vcard_search", "i_vcard_search_sh_lfamily", ["server_host", "lfamily"]), create_index(State, "vcard_search", "i_vcard_search_sh_lgiven", ["server_host", "lgiven"]), diff --git a/test/vcard_tests.erl b/test/vcard_tests.erl index ba1c676d1..e3170f78d 100644 --- a/test/vcard_tests.erl +++ b/test/vcard_tests.erl @@ -31,6 +31,7 @@ recv_presence/1, recv/1]). -include("suite.hrl"). +-include_lib("stdlib/include/assert.hrl"). %%%=================================================================== %%% API @@ -83,9 +84,9 @@ get_set(Config) -> "personal website: http://www.saint-andre.com/">>}, #iq{type = result, sub_els = []} = send_recv(Config, #iq{type = set, sub_els = [VCard]}), - %% TODO: check if VCard == VCard1. - #iq{type = result, sub_els = [_VCard1]} = + #iq{type = result, sub_els = [VCard1]} = send_recv(Config, #iq{type = get, sub_els = [#vcard_temp{}]}), + ?assertEqual(VCard, VCard1), disconnect(Config). service_vcard(Config) ->