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

ASF GitHub Bot commented on IGNITE-8516:
----------------------------------------

GitHub user dgarus opened a pull request:

    https://github.com/apache/ignite/pull/4012

    IGNITE-8516 checked not null constraint

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dgarus/ignite ignite-8516

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/ignite/pull/4012.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4012
    
----
commit 833cb6e8d39ceb830bf77b5c1c50ebbcc7cb565f
Author: sbt-garus-dg <garus.d.g@...>
Date:   2018-05-17T12:06:24Z

    IGNITE-8516 checked not null constraint

----


> 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)

Reply via email to