The simpletest 'Invalid data' currently has one fail in Postgresql (and most likely sqlite too) because of this:

      // 23000 means "Integrity constraint violation" according to ANSI SQL.
      $this->assertEqual($e->errorInfo[0], '23000', t('Exception has proper SQLSTATE.'));

This error code is only returned from MySQL. PostgreSQL returns 23505 - "duplicate key value violates unique constraint", which is more accurate than what MySQL reports back. It would seem to me that were looking for error codes between in the 23000s is that how we want to patch this?

Comments

andypost’s picture

Suppose testing environment should know db type and use local code

andypost’s picture

Another trouble with that issue - this exception handler works inside simpletest's exception handler so sometimes (depends on php version and env config) bring unpredictable results, for example broke batch while returning exception after JSON data

josh waihi’s picture

StatusFileSize
new975 bytes

The simple fact that databases will return different error codes means that this is an unreliable way to write code. It is not a condition Drupal can rely on due to its inconsistantcy between databases.

So lets just remove it and not encourage the use of it in code.

andypost’s picture

Suppose much better to remove this test at all then leave without assert

josh waihi’s picture

Status: Active » Needs review

@andypost, this test does other assertions that are usefull, its merely the error code assertion that is not of any use.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

So lets commit this, I see no useful info in this assertion

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

c960657’s picture

FWIW, Sqlite also returns 23000.

andypost’s picture