ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Kuznetsov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IGNITE-8516) Not null constraint doesn't checked
Date Mon, 21 May 2018 07:57:00 GMT

    [ https://issues.apache.org/jira/browse/IGNITE-8516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16482278#comment-16482278
] 

Alexey Kuznetsov commented on IGNITE-8516:
------------------------------------------

[~garus.d.g] changes looks good to me

> Not null constraint doesn't checked
> -----------------------------------
>
>                 Key: IGNITE-8516
>                 URL: https://issues.apache.org/jira/browse/IGNITE-8516
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 2.4
>            Reporter: Nikolay Izhikov
>            Assignee: Denis Garus
>            Priority: Major
>             Fix For: 2.6
>
>
> User is able to insert null into the not null column through cache-api.
> If one uncomment line {{entries.put(new Organization("2"), new Address("Some address"));}}
- constraint applied and exception would be thrown.
> The same behaviour is expected for the 1 entry map.
> Reproducer:
> {code:java}
> package org.apache.ignite.internal.processors.sql;
> public class IgniteNotNullBug extends GridCommonAbstractTest {
>     @Override protected void beforeTestsStarted() throws Exception {
>         startGrid(0);
>         Set<String> nn = new HashSet<>();
>         nn.add("address");
>         jcache(grid(0), cacheConfiguration(new QueryEntity(Organization.class.getName(),
Address.class.getName())
>             .addQueryField("address", "java.lang.String", "address")
>             .setNotNullFields(nn)), "ORG_ADDRESS");
>     }
>     public void testPutNullField() throws Exception {
>         Map<Organization, Address> entries = new HashMap<>();
>         entries.put(new Organization("1"), new Address(null));
>         //entries.put(new Organization("2"), new Address("Some address"));
>         IgniteCache<Organization, Address> cache = jcache(0, "ORG_ADDRESS");
>         cache.putAll(entries);
>         System.out.println("cache.getConfiguration(CacheConfiguration) = " + cache.getConfiguration(CacheConfiguration.class).getQueryEntities());
>         List<?> objects = execSql("SELECT address FROM ORG_ADDRESS.ADDRESS");
>         
>         assert ((List)objects.get(0)).get(0) == null;
>     }
>     protected CacheConfiguration cacheConfiguration(QueryEntity qryEntity) {
>         CacheConfiguration<?, ?> cache = defaultCacheConfiguration();
>         cache.setCacheMode(CacheMode.PARTITIONED);
>         cache.setAtomicityMode(CacheAtomicityMode.ATOMIC);
>         cache.setBackups(1);
>         cache.setWriteSynchronizationMode(FULL_SYNC);
>         cache.setQueryEntities(Collections.singletonList(qryEntity));
>         return cache;
>     }
>     private List<?> execSql(String sql, Object... args) {
>         SqlFieldsQuery qry = new SqlFieldsQuery(sql)
>             .setArgs(args);
>         return grid(0).context().query().querySqlFields(qry, true).getAll();
>     }
>     private static class Organization implements Serializable {
>         private final String name;
>         private Organization(String name) { this.name = name; }
>     }
>     private static class Address implements Serializable {
>         private final String address;
>         private Address(String address) { this.address = address; }
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message