insert-on-duplicate-key
insert-on-duplicate-key copied to clipboard
Creating wrong record
Hi,
I noticed that in some particular cases the insertOnDuplicateKey
method creates a wrong record in the table. This is an example of input with the table schema, at the very bottom.
Simply inserting the data, starting from an empty table,
AwnRecord::insertOnDuplicateKey($records);
results in the insertion of only 50 records (out of 92 as input) one of which is totally wrong and even invalid, i.e. the is_valid_solarRad
field, defined as boolean
, is equal to 127 and tstamp
, a datetime
field, equals 0000-00-00 00:00:00
(which I believe it's not a valid datetime value)
What's wrong with the code/data?
How can the database even allow for creating an invalid type field?
If of any relevance, I noticed the not inserted records are mostly empty, although null
is a valid value for those columns (and relevant data in my case).
How many unique index is on the table?
The only way I think I can fix the issue if I can replicate it.
Do you have a simple example of a table schema and data to insert.
Sorry @yadakhov I linked the gist but it was probably not really visible. Here you can fine both data and the table schema that in my case generates the issue: https://gist.github.com/stebogit/5b9f2a7cf31ad468ece4bada2c85f91a
The PK is the combination of station_id
and tstamp
:
PRIMARY KEY (station_id, tstamp)
I'll take a look when I got some free time.
I'm suspecting it's the composite primary key. PRIMARY KEY (station_id, tstamp)