You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by sourav dihidar <sd...@gmail.com> on 2021/04/03 15:21:53 UTC

Ignite persistence is accepting null value in not null field

Hi Team,
I am facing one issue
I created one table as below
CREATE TABLE STUDENT
(
ID INTEGER NOT NULL,
NAME VARCHAR(200) NOT NULL,
SALARY INTGER NOT NULL,
PRIMARY KEY(STUDENTID)
)WITH "KEY_TYPE=Tab_Key,VALUE_TYPE=TAB_VALUE";



I used datastreamer to load the data into the table
try(IgniteDataStreamer<BinaryObject,BinaryObject>
stmr=ignite.dataStreamer("SQL_PUBLIC_STUDENT")){
  stmr.keepBinary(true);
  stmr.allowOverwrite(true);
  BinaryObjectBuilder keyBuilder=ignite.binary().builder("Tab_Key");
  BinaryObjectBuilder keyBuilder=ignite.binary().builder("Tab_Value");
  keyBuilder.setField("ID",new Integer(100));
  valueBuilder.setField(" NAME","Petit");// did not insert any value for
SALARY in the value builder
  stmr.addData( keyBuilder.build(), valueBuilder.build());
 }

When I am running this for the first time , data gets inserted with
id=100,name=Petit,salary=null though the SALARY is not null field.
In the second run it gives NULL value is not allowed for column SALARY
Why it is not giving this error in the first run itself.

Thanks

Re: Ignite persistence is accepting null value in not null field

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

Okay, this looks like a bug. Can you please put a small reproducer project
with this code somewhere on github, or provide as tarball? I will try it
and file a ticket, or you can do that yourself.

Regards,
-- 
Ilya Kasnacheev


пн, 5 апр. 2021 г. в 18:16, sourav dihidar <sd...@gmail.com>:

> Thanks for your response.
> Wanted to understand that then how in the second run it is throwing error?
>
> On Mon, Apr 5, 2021, 4:27 PM Ilya Kasnacheev <il...@gmail.com>
> wrote:
>
>> Hello!
>>
>> I guess that "not null" is only tracked by SQL code, but not by cache API
>> or data streamer.
>>
>> Regards,
>> --
>> Ilya Kasnacheev
>>
>>
>> сб, 3 апр. 2021 г. в 18:22, sourav dihidar <sd...@gmail.com>:
>>
>>> Hi Team,
>>> I am facing one issue
>>> I created one table as below
>>> CREATE TABLE STUDENT
>>> (
>>> ID INTEGER NOT NULL,
>>> NAME VARCHAR(200) NOT NULL,
>>> SALARY INTGER NOT NULL,
>>> PRIMARY KEY(STUDENTID)
>>> )WITH "KEY_TYPE=Tab_Key,VALUE_TYPE=TAB_VALUE";
>>>
>>>
>>>
>>> I used datastreamer to load the data into the table
>>> try(IgniteDataStreamer<BinaryObject,BinaryObject>
>>> stmr=ignite.dataStreamer("SQL_PUBLIC_STUDENT")){
>>>   stmr.keepBinary(true);
>>>   stmr.allowOverwrite(true);
>>>   BinaryObjectBuilder keyBuilder=ignite.binary().builder("Tab_Key");
>>>   BinaryObjectBuilder keyBuilder=ignite.binary().builder("Tab_Value");
>>>   keyBuilder.setField("ID",new Integer(100));
>>>   valueBuilder.setField(" NAME","Petit");// did not insert any value for
>>> SALARY in the value builder
>>>   stmr.addData( keyBuilder.build(), valueBuilder.build());
>>>  }
>>>
>>> When I am running this for the first time , data gets inserted with
>>> id=100,name=Petit,salary=null though the SALARY is not null field.
>>> In the second run it gives NULL value is not allowed for column SALARY
>>> Why it is not giving this error in the first run itself.
>>>
>>> Thanks
>>>
>>

Re: Ignite persistence is accepting null value in not null field

Posted by sourav dihidar <sd...@gmail.com>.
Thanks for your response.
Wanted to understand that then how in the second run it is throwing error?

On Mon, Apr 5, 2021, 4:27 PM Ilya Kasnacheev <il...@gmail.com>
wrote:

> Hello!
>
> I guess that "not null" is only tracked by SQL code, but not by cache API
> or data streamer.
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> сб, 3 апр. 2021 г. в 18:22, sourav dihidar <sd...@gmail.com>:
>
>> Hi Team,
>> I am facing one issue
>> I created one table as below
>> CREATE TABLE STUDENT
>> (
>> ID INTEGER NOT NULL,
>> NAME VARCHAR(200) NOT NULL,
>> SALARY INTGER NOT NULL,
>> PRIMARY KEY(STUDENTID)
>> )WITH "KEY_TYPE=Tab_Key,VALUE_TYPE=TAB_VALUE";
>>
>>
>>
>> I used datastreamer to load the data into the table
>> try(IgniteDataStreamer<BinaryObject,BinaryObject>
>> stmr=ignite.dataStreamer("SQL_PUBLIC_STUDENT")){
>>   stmr.keepBinary(true);
>>   stmr.allowOverwrite(true);
>>   BinaryObjectBuilder keyBuilder=ignite.binary().builder("Tab_Key");
>>   BinaryObjectBuilder keyBuilder=ignite.binary().builder("Tab_Value");
>>   keyBuilder.setField("ID",new Integer(100));
>>   valueBuilder.setField(" NAME","Petit");// did not insert any value for
>> SALARY in the value builder
>>   stmr.addData( keyBuilder.build(), valueBuilder.build());
>>  }
>>
>> When I am running this for the first time , data gets inserted with
>> id=100,name=Petit,salary=null though the SALARY is not null field.
>> In the second run it gives NULL value is not allowed for column SALARY
>> Why it is not giving this error in the first run itself.
>>
>> Thanks
>>
>

Re: Ignite persistence is accepting null value in not null field

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

I guess that "not null" is only tracked by SQL code, but not by cache API
or data streamer.

Regards,
-- 
Ilya Kasnacheev


сб, 3 апр. 2021 г. в 18:22, sourav dihidar <sd...@gmail.com>:

> Hi Team,
> I am facing one issue
> I created one table as below
> CREATE TABLE STUDENT
> (
> ID INTEGER NOT NULL,
> NAME VARCHAR(200) NOT NULL,
> SALARY INTGER NOT NULL,
> PRIMARY KEY(STUDENTID)
> )WITH "KEY_TYPE=Tab_Key,VALUE_TYPE=TAB_VALUE";
>
>
>
> I used datastreamer to load the data into the table
> try(IgniteDataStreamer<BinaryObject,BinaryObject>
> stmr=ignite.dataStreamer("SQL_PUBLIC_STUDENT")){
>   stmr.keepBinary(true);
>   stmr.allowOverwrite(true);
>   BinaryObjectBuilder keyBuilder=ignite.binary().builder("Tab_Key");
>   BinaryObjectBuilder keyBuilder=ignite.binary().builder("Tab_Value");
>   keyBuilder.setField("ID",new Integer(100));
>   valueBuilder.setField(" NAME","Petit");// did not insert any value for
> SALARY in the value builder
>   stmr.addData( keyBuilder.build(), valueBuilder.build());
>  }
>
> When I am running this for the first time , data gets inserted with
> id=100,name=Petit,salary=null though the SALARY is not null field.
> In the second run it gives NULL value is not allowed for column SALARY
> Why it is not giving this error in the first run itself.
>
> Thanks
>