Skip to content

Added fields to Exception class to store extra fields added to PostgreSQL9.3 - #22

Closed
david-rowley wants to merge 6 commits into
npgsql:masterfrom
david-rowley:master
Closed

david-rowley wants to merge 6 commits into
npgsql:masterfrom
david-rowley:master

Conversation

@david-rowley

Copy link
Copy Markdown
Contributor

This makes the new error information available in the Exception class
which allows the calling code to, for example see which constraint would
be violated by the request.
See PostgreSQL commit message for more details on what extra information
is available and when. This commit only captures the extra information
when it's there.

http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=991f3e5ab3f8196d18d5b313c81a5f744f3baaea

This makes the new error information available in the Exception class
which allows the calling code to, for example see which constraint would
be violated by the request.
See PostgreSQL commit message for more details on what extra information
is available and when. This commit only captures the extra information
when it's there.

http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=991f3e5ab3f8196d18d5b313c81a5f744f3baaea
This code is untested as I've not yet worked out how to run the test
suit.
The constant values in the Assert.AreEqual() calls may need tweaked.
The prime purpose of the patch is to test that the fields are properly
being populated. There is no need to also test things like foreign key
violation as its testing the same code in Npgsql.
After reading the source code of PostgreSQL9.3, it seem that only
certain errors relating to domain types will populate the DataTypeName
field. This commit adds 2 new tests. 1 to test for the column name, as
the previous uniqueviolation did not show the column name which unique
constraint was violated. Perhaps this has to do with the fact that
unique constraints can exist for >1 column. Test 2 checks the
datatypename after a domain's NOT NULL constraint is violated.

I've not yet run the tests. Though I did compare after setting psql \set
VERBOSITY verbose
Renamed Exception.cs to ExceptionTests.cs and added copyright notice to
the top of the file
Also for the unique violation test I've added some asserts to ensure
that the data type and column name are empty. These are not populated
for unique violations, originally I removed the tests but on after
thought it's probably better to ensure that they're empty strings.
Renamed the 3 new test functions to give them more suitable names. Also
added comment to explain why a domain is created to test the
DataTypeName field. I would have guessed that we could see this
populated by violating a NOT NULL constraint on a table's column, but
this does not seem to be the case.
@franciscojunior

Copy link
Copy Markdown
Member

Merged this pull request to master branch.
Thank you very much, David, for your help with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants