Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FbConnection.GetSchema("Indexes") has wrong value in IS_UNIQUE column [DNET354] #359

Closed
firebird-automations opened this issue Nov 16, 2010 · 2 comments

Comments

@firebird-automations
Copy link

Submitted by: Vladan Bato (vbato)

The DataTable returned by FbConnection.GetSchema("Indexes") has wrong values in the IS_UNIQUE column, due to a bug in the FbIndexes.ProcessResult method that sets the IS_UNIQUE column to 0 (false) for all non-primary keys.

The bug is in the following code:
if (row["PRIMARY_KEY"] == DBNull.Value ||

                  Convert\.ToInt32\(row\["PRIMARY\_KEY"\], CultureInfo\.InvariantCulture\) \!= 0\)

            \{

                row\["IS\_PRIMARY"\] = true;

            \}

            else

            \{

                row\["IS\_UNIQUE"\] = false;

            \}

It mistakenly changes the IS_UNIQUE column to false when the index is not a primary key.
Please note that there is already (in the previous lines) an "if" statement that sets the IS_PRIMARY column, so I don't know what the purpose of this block of code is. Maybe the intent was to set IS_UNIQUE to true for all primary keys (but as far as I can see, rdb$indices.rdb$unique_flag is already set for primary keys)?

This block of code should either be removed entirely or else changed to:
if (row["PRIMARY_KEY"] == DBNull.Value ||
Convert.ToInt32(row["PRIMARY_KEY"], CultureInfo.InvariantCulture) != 0)
{
row["IS_UNIQUE"] = true;
}

Commits: 20ee033

@firebird-automations
Copy link
Author

Commented by: @cincuranet

I agree with you. This code is probably some forgotten piece that should not be there.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.6.1 [ 10400 ]

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

No branches or pull requests

2 participants