Repository navigation
Closed
Description
Hello,
Your NpgsqlDataObjectSupport.xml contains the next definition for TableUniqueKeyColumn (mapped type):
<MappedType name="TableUniqueKeyColumn" underlyingType="ConstraintColumns">
<Selection restrictions="{Catalog}, {Schema}, {Table}, {UniqueKey}, {Name}" filter="constraint_type IN ('PRIMARY KEY', 'UNIQUE')" />
<Identifier>
<Part name="Catalog" underlyingMember="table_catalog" />
<Part name="Schema" underlyingMember="table_schema" />
<Part name="Table" underlyingMember="table_name" />
<Part name="UniqueKey" underlyingMember="constraint_name" />
<Part name="Name" underlyingMember="column_name" />
</Identifier>
<Properties>
<Property name="Name" isIdentifierPart="true" />
<Property name="Ordinal" underlyingMember="ordinal_position" />
</Properties>
</MappedType>
I not sure, but seem you shoud use the "TableUniqueKey" name instead "UniqueKey":
<MappedType name="TableUniqueKeyColumn" underlyingType="ConstraintColumns">
<Selection restrictions="{Catalog}, {Schema}, {Table}, {TableUniqueKey}, {Name}" filter="constraint_type IN ('PRIMARY KEY', 'UNIQUE')" />
<Identifier>
<Part name="Catalog" underlyingMember="table_catalog" />
<Part name="Schema" underlyingMember="table_schema" />
<Part name="Table" underlyingMember="table_name" />
<Part name="TableUniqueKey" underlyingMember="constraint_name" />
<Part name="Name" underlyingMember="column_name" />
</Identifier>
<Properties>
<Property name="Name" isIdentifierPart="true" />
<Property name="Ordinal" underlyingMember="ordinal_position" />
</Properties>
</MappedType>
See TableUniqueKeyColumn defintion in DDEX provider for MSSQL - it uses "TableUniqueKey" name.
<MappedType name="TableUniqueKeyColumn" underlyingType="IndexColumn">
<Selection restrictions="{Catalog},{Schema},{Table},{TableUniqueKey},{Name}" />
<Identifier>
<Part name="Catalog" underlyingMember="Database" />
<Part name="Schema" underlyingMember="Schema" />
<Part name="Table" underlyingMember="Table" />
<Part name="TableUniqueKey" underlyingMember="Index" />
<Part name="Name" underlyingMember="Name" />
</Identifier>
<Properties>
<Property name="Name" isIdentifierPart="true" />
<Property name="Ordinal" underlyingMember="Id" />
</Properties>
</MappedType>
With "UniqueKey" quiery builder (Visual Studio 2017) does not detect the primary key of table.
With "TableUniqueKey" - query builder works without problem.
I tested the own DDEX provider, not your :)
Activity
roji commentedon Jun 10, 2017
@dmitry-lipetsk, thanks for raising this, do you want to submit a PR which fixes this and which I could test?
dmitry-lipetsk commentedon Jun 11, 2017
Hello,
I think, this issue with "UniqueKey" can be looked through next sequence:
Trace of calls:
Here name of UniqueKey is "INTEG_2". See the
OleDbDataObjectEnumerator_TableUniqueKeyColumns::SelectObjects("TableUniqueKeyColumn",{"COUNTRY","INTEG_2",null},null,null)When I use "UniqueKey" name (instead "TableUniqueKey"), I see the
OleDbDataObjectEnumerator_TableUniqueKeyColumns::SelectObjects("TableUniqueKeyColumn",{"COUNTRY","{UniqueKey}",null},null,null)And, as result, SelectObjects returns the empty set.
I think, your DDEX provider (with "UniqueKey" name) has the same issue.
roji commentedon Jun 11, 2017
Thanks for the instructions, I'll take a look in the coming days. Are you working on another DDEX provider of your own (not Npgsql)?
Do you plan to submit a PR which fixes this problem?
dmitry-lipetsk commentedon Jun 11, 2017
Yes. It is DDEX provider for lcpi.data.oledb (see at nuget). I use your (and others) provider as base sample :)
No. I just want to inform you about possible problem :)
roji commentedon Jun 11, 2017
Ok thanks, I'll take a look. If you have experience with DDEX and can give us a hand (as you've done here) it would be greatly appreciated, I'm lacking DDEX experience (and time).
roji commentedon Jun 12, 2017
@dmitry-lipetsk, I tried to simply change UniqueKey to TableUniqueKey as you suggest, with no visible effect:
In my query builder, the key column still does not show up as bold. I tried looking around a bit but couldn't make it work - the lack of real, useful documentation on DDEX is really quite incredible.
Can you let me know how you got the DDEX trace log? I never saw that and it could be useful. I'm sure that you're right and that something isn't quite right in how Npgsql is doing things, but I don't have enough time to dive into this at the moment.
dmitry-lipetsk commentedon Jun 12, 2017
Hello,
May be the problem with your "IsPrimary" property?
Look to my ObjectSupport.xml (I generate it in runtime).
Types:
MappedTypes:
When I add the table "COUNTRY" (primary key column - "COUNTRY"), I get the next trace log:
higuchi-daisuke commentedon Nov 1, 2017
Hello,
I have a plan to submit a PR which fixes this.
Could you tell me which DDEX tests should be run?
Currently, automated tests (npgsql/test/Npgsql.Tests) were already passed,
and I confirmed that the primary key column was displayed with bold font in querybuilder.
Are there other tests to be run?
roji commentedon Nov 1, 2017
@higuchi-daisuke IIRC there are no automated tests (in Npgsql.Tests) which do anything DDEX-related - the only way to test is to build the VSIX and see the effect of your modification.
higuchi-daisuke commentedon Nov 1, 2017
@roji Thank you for this information. I will submit a PR later.
Fix issue npgsql#1597
Correct VSIX detection for primary keys
Correct VSIX detection for primary keys