@@ -1584,7 +1584,7 @@ although it may exist in data created by Tarantool's NoSQL. In SQL, -nan is trea
1584
1584
1585
1585
A string will be converted to a number if it is used with an arithmetic operator and conversion is possible,
1586
1586
for example ``'7' + '7' `` = 14.
1587
- And for comparison or assignment , ``'7' `` = 7.
1587
+ And for comparison, ``'7' `` = 7.
1588
1588
This is called implicit casting. It is applicable for STRINGs and all numeric data types.
1589
1589
1590
1590
Limitations: (`Issue#2346 <https://github.com/tarantool/tarantool/issues/2346 >`_) |br |
@@ -1685,8 +1685,8 @@ The specific situations in this chart follow the general rules:
1685
1685
~ To BOOLEAN | To number | To STRING | To VARBINARY
1686
1686
--------------- ---------- ---------- --------- ------------
1687
1687
From BOOLEAN | AAA | S-- | A-- | ---
1688
- From number | A-- | SSA | AAA | ---
1689
- From STRING | S-- | SSS | AAA | A--
1688
+ From number | A-- | SSA | A-A | ---
1689
+ From STRING | S-- | S-S | AAA | A--
1690
1690
From VARBINARY | --- | --- | A-- | AAA
1691
1691
1692
1692
Where each entry in the chart has 3 characters: |br |
@@ -1728,6 +1728,12 @@ The result is TRUE.
1728
1728
column is AAA and the third letter of AAA is for implicit cast (comparison) and A means Always Allowed.
1729
1729
The result is TRUE. For detailed explanation see the following section.
1730
1730
1731
+ ``CAST('5' AS INTEGER) `` is legal because the intersection of the "From STRING" row with the "To number"
1732
+ column is S-S and the first letter of S-S is for explicit cast and S means Sometimes Allowed.
1733
+ However, ``CAST('5.5' AS INTEGER) `` is illegal because 5.5 is not an integer --
1734
+ if the string contains post-decimal digits and the target is INTEGER or UNSIGNED,
1735
+ the assignment will fail.
1736
+
1731
1737
Implicit string/numeric cast
1732
1738
1733
1739
Special considerations may apply for casting STRINGs
@@ -1743,15 +1749,11 @@ Therefore ``1e400 < ''`` is TRUE. |br|
1743
1749
Exception: for BETWEEN the cast is to the data type of the first and last operands. |br |
1744
1750
Therefore ``'66' BETWEEN 5 AND '7' `` is TRUE.
1745
1751
1746
- For assignments, the cast is always from source to target.
1747
- Therefore ``INSERT INTO t (integer_column) VALUES ('5'); `` inserts 5. |br |
1748
- If the cast fails, then the result is an error.
1749
- Due to a change in behavior starting with Tarantool 2.4.1,
1750
- if the string contains post-decimal digits and the target is INTEGER or UNSIGNED,
1751
- the assignment will fail.
1752
- Therefore ``INSERT INTO t (integer_column) VALUES ('5.5'); `` causes an error. |br |
1752
+ For assignments, due to a change in behavior starting with Tarantool 2.5.1,
1753
+ implicit casts from strings to numbers are not legal. Therefore
1754
+ ``INSERT INTO t (integer_column) VALUES ('5'); `` is an error.
1753
1755
1754
- Implicit cast also happens if STRINGS are used in arithmetic. |br |
1756
+ Implicit cast does happen if STRINGS are used in arithmetic. |br |
1755
1757
Therefore ``'5' / '5' = 1 ``. If the cast fails, then the result is an error. |br |
1756
1758
Therefore ``'5' / '' `` is an error.
1757
1759
@@ -4787,7 +4789,7 @@ and returns:
4787
4789
- row_count: 1
4788
4790
...
4789
4791
4790
- It is functionally the same thing as an :ref: `UPDATE statement :
4792
+ It is functionally the same thing as an :ref: `UPDATE Statement < sql_update >` :
4791
4793
4792
4794
.. code-block :: none
4793
4795
0 commit comments