From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rhino.ch-server.com (rhino.ch-server.com [209.59.190.103]) (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 F3E464696C3 for ; Thu, 30 Apr 2020 17:15:57 +0300 (MSK) References: <20200213142534.GA26443@tarantool.org> <36e21524-35d7-9f54-5953-32863df95709@tarantool.org> <20200430123500.GA6499@atlas> <8c71af0d-3693-82d5-4b15-f7b7fe38062c@tarantool.org> <20200430130947.GC6499@atlas> <2a788af3-6efe-bce8-1509-f7e08639b36f@tarantool.org> <20200430140414.GD6499@atlas> From: Peter Gulutzan Message-ID: Date: Thu, 30 Apr 2020 08:15:52 -0600 MIME-Version: 1.0 In-Reply-To: <20200430140414.GD6499@atlas> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [Tarantool-discussions] Implicit cast for ASSIGNMENT List-Id: Tarantool development process List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Konstantin Osipov , Imeev Mergen Cc: tarantool-discussions@dev.tarantool.org Hi, On 2020-04-30 8:04 a.m., Konstantin Osipov wrote: > * Imeev Mergen [20/04/30 16:14]: >> >> On 4/30/20 4:09 PM, Konstantin Osipov wrote: >>> * Imeev Mergen [20/04/30 15:59]: >>>>> The only possible exception is conversion of a lossless conversion >>>>> of a numeric literal, e.g.: >>>>> >>>>> float_val = 1.1 -- implicitly convert decimal constant 1.1 to float >>>> So, is it fine to implicitly cast 1.0(DOUBLE) to 1(INTEGER)? >>> 1.0 is not double, it's DECIMAL. >> Ok, then, let's say we executed something like this: >> >> box.execute('CREATE TABLE t (i INT PRIMARY KEY);') >> box.execute('INSERT INTO t VALUES(CAST(1 AS DOUBLE));') >> >> Should this work of we should receive an error? > > I think it shouldn't because CAST(1 AS DOUBLE) is an expression, > not a constant literal. > I of course think that it should work, but K. Yukhin decided it should not work. With regard to the earlier questions Unfortunately assigning 1.1 to an INTEGER fails. "Implicit casting among the numeric data types" is a mandatory feature of standard SQL, My opinion was that implicit cast should be legal https://github.com/tarantool/tarantool/issues/4216 However, K. Yukhin closed that issue. I also believed that typeof(1.0) should be DECIMAL. https://github.com/tarantool/tarantool/issues/4415 But currently typeof(1.0) is DOUBLE. Peter Gulutzan