Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Serge Petrenko <sergepetrenko@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [PATCH] lua: fix decimal comparison with box.NULL
Date: Tue, 27 Aug 2019 15:04:48 +0300	[thread overview]
Message-ID: <20190827120448.GN13834@esperanza> (raw)
In-Reply-To: <20190827112209.43581-1-sergepetrenko@tarantool.org>

On Tue, Aug 27, 2019 at 02:22:09PM +0300, Serge Petrenko wrote:
> This problem is similar to the one fixed in commit
> 3c6c1cc96a1a510493c21c472565d4063e403ba2 (lua:fix decimal comparison
> with nil)
> We should handle box.NULL the same way.
> 
> Closes #4454
> ---
> https://github.com/tarantool/tarantool/issues/4454
> https://github.com/tarantool/tarantool/tree/sp/gh-4454-decimal-cmp-null
> 
>  src/lua/decimal.c         |  3 ++-
>  test/app/decimal.result   | 30 ++++++++++++++++++++++++++++++
>  test/app/decimal.test.lua |  8 ++++++++
>  3 files changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lua/decimal.c b/src/lua/decimal.c
> index 23e50ba68..8905a0b9d 100644
> --- a/src/lua/decimal.c
> +++ b/src/lua/decimal.c
> @@ -235,7 +235,8 @@ static int
>  ldecimal_eq(struct lua_State *L)
>  {
>  	assert(lua_gettop(L) == 2);
> -	if (lua_isnil(L, 1) || lua_isnil(L, 2)) {
> +	if (lua_isnil(L, 1) || lua_isnil(L, 2) ||
> +	    luaL_isnull(L, 1) || luaL_isnull(L, 2)) {
>  		lua_pushboolean(L, false);
>  		return 1;
>  	}
> diff --git a/test/app/decimal.result b/test/app/decimal.result
> index 8251e13d8..90d0984b0 100644
> --- a/test/app/decimal.result
> +++ b/test/app/decimal.result
> @@ -248,6 +248,36 @@ a <= nil
>   | ---
>   | - error: '[string "return a <= nil "]:1: attempt to compare decimal with nil'
>   | ...
> +-- and with box.NULL
> +--
> +a == box.NULL
> + | ---
> + | - false
> + | ...
> +a ~= box.NULL
> + | ---
> + | - true
> + | ...
> +a > box.NULL
> + | ---
> + | - error: '[string "return a > box.NULL "]:1: expected decimal, number or string as
> + |     1 argument'
> + | ...

1 argument?

> +a < box.NULL
> + | ---
> + | - error: '[string "return a < box.NULL "]:1: expected decimal, number or string as
> + |     2 argument'
> + | ...

2 argument?

Why does the error message differ for the two seemingly equivalent
cases? What's "1 argument"?

Note, in case of comparison with nil the error message is different:

 | - error: '[string "return a > nil "]:1: attempt to compare decimal with nil'
 | - error: '[string "return a < nil "]:1: attempt to compare decimal with nil'

  reply	other threads:[~2019-08-27 12:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 11:22 Serge Petrenko
2019-08-27 12:04 ` Vladimir Davydov [this message]
2019-08-27 12:10   ` [tarantool-patches] " Serge Petrenko
2019-08-27 12:25     ` Vladimir Davydov
2019-08-27 12:37       ` Serge Petrenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190827120448.GN13834@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH] lua: fix decimal comparison with box.NULL' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox