Hi,
Lets discuss SQL DML (INSERT/UPDATE) current behavior specific:
Ignite doesn't check a type of input objects when hidden columns _key,
_value is used in a DML statements.
I describe the current behavior for example:
1. Cache configuration: 'setIndexedTypes(PersonKey.class, Person.class))'
2. PersonKey type contains 'int id' field.
3. SQL statement: 'INSERT INTO test (_val, _key) VALUES (?, ?)'
Cases:
1. Invalid value object type:
- Any value object may be passed as a query parameter
- Query is executed without an error and returns '1' (one row updated);
- There is not inserted row at the 'SELECT * FROM test' results.
- cache.get(key) returns inserted object;
2. Invalid key object type:
2.1 Non-primitive object is passed and binary representation doesn't
contain 'id' field.
- Query is executed without error and returns '1' (one row updated);
- The inserted row is available by 'SELECT *' and the row contains id =
null;
2.2 Non-primitive object is passed and binary representation contains
'id' field.
- The inserted row is available by 'SELECT *' and the row contains
expected 'id' field;
- The cache entry cannot be gathered by 'cache.get' operation with the
corresponding 'PersonKey(id)' (keys differ).
I propose to check type of the user's input object.
I guess that using _key/_val columns works close to 'cache.put()' but it
looks like significant usability issue.
To confuse the 'PersonKey.class.getName()' and
'node.binary().builder("PersonKey")' is a typical mistake of Ignite
newcomers.
One more argument for check: SQL INSERT sematic means the row is
inserted into the specified TABLE, not into the cache.
So, throw IgniteSQLException is expected behavior in this case, i think.
[1]. https://issues.apache.org/jira/browse/IGNITE-5250
--
Taras Ledkov
Mail-To: tled...@gridgain.com