[ 
https://issues.apache.org/jira/browse/IGNITE-22965?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maksim Zhuravkov updated IGNITE-22965:
--------------------------------------
    Description: 
Example:

{noformat}
  @Test
    public void testDec() {
        sql("CREATE TABLE t(k INT PRIMARY KEY, v DECIMAL(3,1))");

        RuntimeException err1 = assertThrows(RuntimeException.class, () -> 
sql("INSERT INTO t(k, v) VALUES (1, 300.1)"));
        assertEquals("Numeric field overflow", err1.getMessage());

        RuntimeException err2 = assertThrows(RuntimeException.class, () -> {
            IgniteImpl ignite = CLUSTER.aliveNode();
            KeyValueView<Tuple, Tuple> kv = 
ignite.tables().table("t").keyValueView();

            kv.put(null, Tuple.create().set("k", 1), Tuple.create().set("v", 
new BigDecimal("300.1")));
        });
        assertEquals("Numeric field overflow in column 'V'", err2.getMessage());

        // This assertion fails and a record is successfully added.
        RuntimeException err3 = assertThrows(RuntimeException.class, () -> {
            KeyValueView<Tuple, Tuple> kv = 
client.tables().table("t").keyValueView();

            kv.put(null, Tuple.create().set("k", 1), Tuple.create().set("v", 
new BigDecimal("300.1")));
        });
        assertEquals(err3.getMessage(), "Numeric field overflow in column 'V'");
    }
{noformat}


  was:
Example:

{noformat}
  @Test
    public void testDec() {
        sql("CREATE TABLE t(k INT PRIMARY KEY, v DECIMAL(3,1))");

        RuntimeException err1 = assertThrows(RuntimeException.class, () -> 
sql("INSERT INTO t(k, v) VALUES (1, 300.1)"));
        assertEquals("Numeric field overflow", err1.getMessage());

        RuntimeException err2 = assertThrows(RuntimeException.class, () -> {
            IgniteImpl ignite = CLUSTER.aliveNode();
            KeyValueView<Tuple, Tuple> kv = 
ignite.tables().table("t").keyValueView();

            kv.put(null, Tuple.create().set("k", 1), Tuple.create().set("v", 
new BigDecimal("300.1")));
        });
        assertEquals("Numeric field overflow in column 'V'", err2.getMessage());

        // This assertion fails.
        RuntimeException err3 = assertThrows(RuntimeException.class, () -> {
            KeyValueView<Tuple, Tuple> kv = 
client.tables().table("t").keyValueView();

            kv.put(null, Tuple.create().set("k", 1), Tuple.create().set("v", 
new BigDecimal("300.1")));
        });
        assertEquals(err3.getMessage(), "Numeric field overflow in column 'V'");
    }
{noformat}



> Decimal type precision is ignored by client kv/record APIs
> ----------------------------------------------------------
>
>                 Key: IGNITE-22965
>                 URL: https://issues.apache.org/jira/browse/IGNITE-22965
>             Project: Ignite
>          Issue Type: Bug
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>              Labels: ignite-3
>
> Example:
> {noformat}
>   @Test
>     public void testDec() {
>         sql("CREATE TABLE t(k INT PRIMARY KEY, v DECIMAL(3,1))");
>         RuntimeException err1 = assertThrows(RuntimeException.class, () -> 
> sql("INSERT INTO t(k, v) VALUES (1, 300.1)"));
>         assertEquals("Numeric field overflow", err1.getMessage());
>         RuntimeException err2 = assertThrows(RuntimeException.class, () -> {
>             IgniteImpl ignite = CLUSTER.aliveNode();
>             KeyValueView<Tuple, Tuple> kv = 
> ignite.tables().table("t").keyValueView();
>             kv.put(null, Tuple.create().set("k", 1), Tuple.create().set("v", 
> new BigDecimal("300.1")));
>         });
>         assertEquals("Numeric field overflow in column 'V'", 
> err2.getMessage());
>         // This assertion fails and a record is successfully added.
>         RuntimeException err3 = assertThrows(RuntimeException.class, () -> {
>             KeyValueView<Tuple, Tuple> kv = 
> client.tables().table("t").keyValueView();
>             kv.put(null, Tuple.create().set("k", 1), Tuple.create().set("v", 
> new BigDecimal("300.1")));
>         });
>         assertEquals(err3.getMessage(), "Numeric field overflow in column 
> 'V'");
>     }
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to