I am using DBI, RMySql packages for interacting with MySql database.
Here are more details about configuration:
- R version: 3.3.2
- DBI version: 0.7
- RMySql version: 0.10.13
Below is the schema for table Site:
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| short_name | varchar(10) | NO | UNI | NULL | |
| full_name | varchar(50) | NO | UNI | NULL | |
+------------+-------------+------+-----+---------+----------------+
As you can see that the fields short_name & full_name are having UNIQUE & NOT NULL constraints.
On trying to insert a row with the duplicate short_name or full_name which already exist in the table, dbWriteTable does not let happen such row insertion but it returns the TRUE status even though it violates the UNIQUE constraint. Same thing happens for NOT NULL constraint as well.
Is this the expected behavior of DBI & dbWriteTable? Why it's not returning the FALSE status?
EDIT: I also observed that even dbSendStatement() and dbSendQuery() does not give any error in case of constraint violation. Is there any way to get to know this?