Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Won't Fix
-
None
-
None
-
None
Description
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:
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(); } }
Attachments
Issue Links
- is related to
-
IGNITE-8331 SQL: Add Decimal precision and scale constraint
- Resolved