From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 1AECB6EC40; Fri, 13 Aug 2021 13:22:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1AECB6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628850134; bh=RWIO9NvzvbaxoXtJyYt94+8C4oL4qNlAwK3/adLIStY=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yqYvbbTlwiGQ+TaYSk1QvYxREDcA1oASJML/HybNVrrTTOr5nnIwkPx5X9JUIeRmE jtw6gnvkt7RkjtvhBTpmTABQaT7m31UtdUspDQZF/mMuLqi9yPKF5SOaPZZxqALJcx /A6lHLxVNz0imIdzkyX+lYz7M47u3zB5H4Z7RShc= Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id F141F6EC40 for ; Fri, 13 Aug 2021 13:22:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F141F6EC40 Received: by smtp33.i.mail.ru with esmtpa (envelope-from ) id 1mEUKJ-0000cU-Vx; Fri, 13 Aug 2021 13:22:12 +0300 To: Oleg Babin , vdavydov@tarantool.org, sergos@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <3a954f7793e6356cefb8cd0151a6434382ec876c.1628810253.git.sergepetrenko@tarantool.org> Message-ID: <9b40f22d-49ad-23fb-35f8-3187612d9086@tarantool.org> Date: Fri, 13 Aug 2021 13:22:11 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD906AB4890CDABF0C5CB76CEE71D3E4007182A05F53808504095270CAC6FDC40991F30BD8AC3D5A7B9B8EE05985114C6A0BC9E0720A867156D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D3DF794D859AA4BFEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379A70878BADDF00B98638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85BA0489F439749412F4E84341F9F8B8A117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520B1593CA6EC85F86DE5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE0AC5B80A05675ACD1AB2475877E8919AD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3A7DFDF579AB090EF040F9FF01DFDA4A8C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637C3090DF2C0002BD1EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505CDF7A50717662B807E359F401688FC1C X-C1DE0DAB: 0D63561A33F958A524586CCBE42C9595A9FC818F3464F9B45D54E42EED55596AD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA750E14360347543F58410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D75CEA0D7A80616E60D164185A48DBE0D14AC58A5DE91CA2CF6663567FB24B196F07CE16B17A69BD1D7E09C32AA3244C0068DBEF327427DC6FBFEA3FDD90F602F26BFA4C8A6946B8927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj0dLV0c3jbkwCdPgw4UYhTg== X-Mailru-Sender: 583F1D7ACE8F49BD31DE23046B3A846085BACDEC66BF16F1F19682A3BA8CFCC293776BB9205588BC6BB2E709EA627F343C7DDD459B58856F0E45BC603594F5A135B915D4279FF0579437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 1/2] lua: introduce table.equals method X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 13.08.2021 08:30, Oleg Babin пишет: > Thanks for your patch. > > > It seems it works in quite strange way: > > ``` > > tarantool> table.equals({a = box.NULL}, {}) > --- > - true > ... > > tarantool> table.equals({}, {a = box.NULL}) > --- > - false > ... > > ``` > > > I can change arguments order to get different result. Expected false > in both cases. > > For tap it was considered as buggy behaviour > https://github.com/tarantool/tarantool/issues/4125 > > ==================================== Good catch! Thanks! Check out the diff: diff --git a/src/lua/table.lua b/src/lua/table.lua index 5f35a30f6..3d5e69e97 100644 --- a/src/lua/table.lua +++ b/src/lua/table.lua @@ -63,7 +63,7 @@ end  -- @return true when the two tables are equal (false otherwise).  local function table_equals(a, b)      if type(a) ~= 'table' or type(b) ~= 'table' then -        return a == b +        return type(a) == type(b) and a == b      end      local mt = getmetatable(a)      if mt and mt.__eq then diff --git a/test/app-tap/table.test.lua b/test/app-tap/table.test.lua index a3c9aa123..ec81593f3 100755 --- a/test/app-tap/table.test.lua +++ b/test/app-tap/table.test.lua @@ -8,7 +8,7 @@ yaml.cfg{      encode_invalid_as_nil  = true,  }  local test = require('tap').test('table') -test:plan(38) +test:plan(40)  do -- check basic table.copy (deepcopy)      local example_table = { @@ -227,6 +227,10 @@ do -- check table.equals      test:ok(table.equals({}, {}), "table.equals for empty tables")      test:is(table.equals({}, {1}), false, "table.equals with one empty table")      test:is(table.equals({1}, {}), false, "table.equals with one empty table") +    test:is(table.equals({key = box.NULL}, {key = nil}), false, +            "table.equals for box.NULL and nil") +    test:is(table.equals({key = nil}, {key = box.NULL}), false, +            "table.equals for box.NULL and nil")      local tbl_a = {          first = {              1, ==================================== > On 13.08.2021 02:30, Serge Petrenko via Tarantool-patches wrote: >> Introduce table.equals for comparing tables. >> The method respects __eq metamethod, if provided. >> >> Needed-for #5894 >> --- >> -- Serge Petrenko