LinuxDoku / migratordotnet

Automatically exported from code.google.com/p/migratordotnet
0 stars 0 forks source link

Setting twice PrimaryKeyWithIdentity instead of throwing an exception creates wrong data. #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add a migration with two PrimaryKeyWithIdentity columns

What is the expected output? What do you see instead?
The expected ouput will be an exception (only one Primary Key is accepted 
in a DB).
Instead of this every column is generated but some of the options where 
ignored, i had two null columns that were getting notnull after this

What version of the product are you using? On what operating system?
trunk

Please provide any additional information below.
Changing the PrimaryKeyWithIdentity to the right configuration i wanted 
(Not Null) solved the issue. 

It is a minor problem because the cause was negligent cut & paste, but it 
may be nice to have an exception in this case.

Original issue reported on code.google.com by gustavo.ringel@gmail.com on 9 Jun 2008 at 12:26

GoogleCodeExporter commented 8 years ago
Ok, my concept was wrong, two primary keys was used for a compound key 
(searched at 
the code by now)
The problem is that you are removing the primarykey property from the columns 
when 
it is a compound key, because you are adding it later, but in the way you also 
remove the notnull and for every column!!! 
I'm correcting + creating a patch including a test for this.

Original comment by gustavo.ringel@gmail.com on 9 Jun 2008 at 12:58

GoogleCodeExporter commented 8 years ago
The included patch has the following:

Test that SQLTransformationProvider GetColumns knows if the column is nullable.

Test that setting null properties for other columns when the table has a 
compound 
key doesn't set the other collumns to not null (what it was currently doing)

I suggest to apply it...

Currently is somewhat hard to test because of the absence of a GetColumn() in 
the 
_provider...i'm traversing the columns array in the tests for this...may be you 
should consider to add this.

Additionaly i added the test about IsNullable to the 
SQLTransformationProvider...it 
should have been added to the base class, but first of all we should write for 
every 
provider the improved GetColumns...if it is right what i have started...i 
didn't add 
more properties until i know if you are ok with this.

Original comment by gustavo.ringel@gmail.com on 9 Jun 2008 at 1:56

GoogleCodeExporter commented 8 years ago
Sorry, here is the patch

Original comment by gustavo.ringel@gmail.com on 9 Jun 2008 at 1:56

Attachments:

GoogleCodeExporter commented 8 years ago
SVN 81
Thanks to Gustavo for finding this issue and starting the solution.

 * Added a fix for not removing Null constraints from non-PK columns in a compound PK 
   scenario.
 * Enhanced the GetColumns to also figure out the Nullability of columns on all the 
   providers except Oracle because I don't have access to it.

Original comment by geoffl...@gmail.com on 10 Jun 2008 at 8:57