[ https://issues.apache.org/jira/browse/IGNITE-10066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Roman Kondakov updated IGNITE-10066: ------------------------------------ Labels: mvcc_stabilization_stage_1 transactions (was: ) > Missing key and value constraint validation for MVCC tables > ----------------------------------------------------------- > > Key: IGNITE-10066 > URL: https://issues.apache.org/jira/browse/IGNITE-10066 > Project: Ignite > Issue Type: Bug > Components: mvcc > Reporter: PetrovMikhail > Priority: Major > Labels: mvcc_stabilization_stage_1, transactions > Fix For: 2.8 > > > It seems that key and value constraints for MVCC tables are ignoring now when > code approach is using to operate with table. The same SQL requests work fine. > It seems that QueryTypeDescriptorImpl.validateKeyAndValue method call which > provides corresponding constraints is missed now. > > Reproducer for not null constraint: > {code:java} > public class IgniteCacheTransactionalSnapshotNullConstraintTest extends > GridCommonAbstractTest { > private static final String REPLICATED_CACHE_NAME = "replicatedCacheName"; > private static final String PARTITIONED_CACHE_NAME = > "partitionedCacheName"; > @Override protected void beforeTestsStarted() throws Exception { > startGrid(0); > execSQL("CREATE TABLE table(id INT PRIMARY KEY, str VARCHAR NOT NULL) > WITH \"atomicity=transactional_snapshot\""); > jcache(grid(0), cacheConfiguration(REPLICATED, > TRANSACTIONAL_SNAPSHOT), REPLICATED_CACHE_NAME); > jcache(grid(0), cacheConfiguration(PARTITIONED, > TRANSACTIONAL_SNAPSHOT), PARTITIONED_CACHE_NAME); > } > protected CacheConfiguration cacheConfiguration(CacheMode cacheMode, > CacheAtomicityMode atomicityMode) { > CacheConfiguration cfg = new CacheConfiguration(); > cfg.setCacheMode(cacheMode); > cfg.setAtomicityMode(atomicityMode); > cfg.setWriteSynchronizationMode(FULL_SYNC); > cfg.setQueryEntities(Collections.singletonList(new > QueryEntity(Integer.class, Person.class))); > return cfg; > } > public void testPutNullValueReplicatedModeFail() throws Exception { > IgniteCache<Integer, Person> cache = jcache(0, REPLICATED_CACHE_NAME); > assertThrowsWithCause(() -> { > cache.put(0, new Person(null, 25)); > }, IgniteException.class); > } > public void testPutNullValuePartitionedModeFail() throws Exception { > IgniteCache<Integer, Person> cache = jcache(0, > PARTITIONED_CACHE_NAME); > assertThrowsWithCause(() -> { > cache.put(1, new Person(null, 18)); > }, IgniteException.class); > } > public void testPutNullValueSQLFail() throws Exception { > checkSQLThrows("INSERT INTO table VALUES(?, ?)", NULL_VALUE, 0, null); > } > public static class Person implements Serializable { > @QuerySqlField(notNull = true) > private String name; > @QuerySqlField > private int age; > public Person(String name, int age) { > this.name = name; > this.age = age; > } > } > private void checkSQLThrows(String sql, String sqlStateCode, Object... > args) { > IgniteSQLException err = > (IgniteSQLException)GridTestUtils.assertThrowsWithCause(() -> { > execSQL(sql, args); > return 0; > }, IgniteSQLException.class); > assertEquals((err).sqlState(), sqlStateCode); > } > private List<?> execSQL(String sql, Object... args) { > SqlFieldsQuery qry = new SqlFieldsQuery(sql) > .setArgs(args); > return grid(0).context().query().querySqlFields(qry, true).getAll(); > } > } > {code} > -- This message was sent by Atlassian JIRA (v7.6.3#76005)