Ignite persistence is accepting null value in not null field

classic Classic list List threaded Threaded
4 messages Options
sourav dihidar sourav dihidar
Reply | Threaded
Open this post in threaded view
|

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
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

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

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 <[hidden email]>:
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
sourav dihidar sourav dihidar
Reply | Threaded
Open this post in threaded view
|

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

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 <[hidden email]> 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 <[hidden email]>:
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
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

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

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 <[hidden email]>:
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 <[hidden email]> 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 <[hidden email]>:
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