From f51ba687e213cdc4136138cba39bb8bc022097ab Mon Sep 17 00:00:00 2001 From: Evgeny Khramtsov Date: Mon, 28 Oct 2019 12:19:24 +0300 Subject: [PATCH] Escape 'family' field in SQL requests This is needed for compatibility with CockroachDB, because 'FAMILY' is a reserved keyword in this database. --- src/mod_vcard_sql.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mod_vcard_sql.erl b/src/mod_vcard_sql.erl index 6b604161f..85f6aefd6 100644 --- a/src/mod_vcard_sql.erl +++ b/src/mod_vcard_sql.erl @@ -102,7 +102,7 @@ set_vcard(LUser, LServer, VCARD, "!server_host=%(LServer)s", "fn=%(FN)s", "lfn=%(LFN)s", - "family=%(Family)s", + "\"family\"=%(Family)s", "lfamily=%(LFamily)s", "given=%(Given)s", "lgiven=%(LGiven)s", @@ -136,7 +136,7 @@ search(LServer, Data, AllowReturnAll, MaxMatch) -> end, case catch ejabberd_sql:sql_query( LServer, - [<<"select username, fn, family, given, " + [<<"select username, fn, \"family\", given, " "middle, nickname, bday, ctry, " "locality, email, orgname, orgunit " "from vcard_search ">>, @@ -192,7 +192,7 @@ remove_user(LUser, LServer) -> " where lusername=%(LUser)s and %(LServer)H")) end). -export(_Server) -> +export(_Server) -> [{vcard, fun(Host, #vcard{us = {LUser, LServer}, vcard = VCARD}) when LServer == Host -> @@ -227,7 +227,7 @@ export(_Server) -> "server_host=%(LServer)s", "fn=%(FN)s", "lfn=%(LFN)s", - "family=%(Family)s", + "\"family\"=%(Family)s", "lfamily=%(LFamily)s", "given=%(Given)s", "lgiven=%(LGiven)s",