1

We have a two column unique constraint for web scraping. url + javascriptPath. url cannot be null and javascriptPath is null a ton.

BUT when we insert these two values, it succeeds instead of properly failing

and we end up with two rows so when we search on http://myurl and javascriptPath=null, it fails on us as we expected one result.

How to do this uniqueness constraint?

thanks, Dean

Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
  • 1
    `javascriptPath = null` should be `javascriptPath IS null`. Voting to close this as a typo. – GMB May 23 '20 at 00:31
  • Unfortunately (or not, depending on your perspective), MySQL allows you to insert `NULL` into a unique key more than once. – Nick May 23 '20 at 01:02

0 Answers0