Skip to content

Add support for index operators#662

Merged
austindrenski merged 3 commits intonpgsql:devfrom
khellang:index-operators
Nov 14, 2018
Merged

Add support for index operators#662
austindrenski merged 3 commits intonpgsql:devfrom
khellang:index-operators

Conversation

@khellang
Copy link
Copy Markdown
Contributor

@khellang khellang commented Oct 9, 2018

Just picking up the good work done by @quanterion in #257.

I tried looking at scaffolding support as well, but it was a bit involved, so figured I'd punt on it for now and focus on getting the runtime support in.

Closes #481

Copy link
Copy Markdown
Contributor

@austindrenski austindrenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks interesting, thanks for this! Just a few nits here.

string IndexColumnList(string[] columns, string[] operators)
{
if (operators == null || operators.Length == 0)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: omit

var @operator = operators[i];

if (string.IsNullOrEmpty(@operator))
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: omit

var identifier = Dependencies.SqlGenerationHelper.DelimitIdentifier(v);

if (i >= operators.Length)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: omit

@khellang
Copy link
Copy Markdown
Contributor Author

khellang commented Oct 9, 2018

Looks like the CI failure is unrelated?

@austindrenski
Copy link
Copy Markdown
Contributor

I think so, just started a rebuild on AppVeyor.

@khellang
Copy link
Copy Markdown
Contributor Author

khellang commented Oct 9, 2018

Indeed 🎉

Copy link
Copy Markdown
Contributor

@austindrenski austindrenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just took another look, and it looks good so far. Two additional considerations:

  1. Would it be much more work to add support for sort options?
  2. Could you take a look at how the current implementation handles a schema-qualified operator class?
    • This may not be an issue here (or already be handled)...but I want to make sure we've covered the bases, given the recent work on schema-qualified types (#605, #626).

@khellang
Copy link
Copy Markdown
Contributor Author

khellang commented Oct 10, 2018

1. Would it be much more work to add support for sort options?

I don't know. It would definitely add to the complexity. If it's OK with you, I'd like to punt on it for now and maybe take a look at them later. I really need operator support, whereas I have never used or seen sort options being used before.

2. Could you take a look at how the current implementation handles a schema-qualified operator class?

You mean if someone pass myschema.blah_ops?

@austindrenski
Copy link
Copy Markdown
Contributor

I don't know. It would definitely add to the complexity. If it's OK with you, I'd like to punt on it for now and maybe take a look at them later. I really need operator support, whereas I have never used or seen sort options being used before.

OK that sounds good—just wanted to make sure it wasn't an unintentional punt.

You mean if someone pass myschema.blah_ops?

Yes. For example, in the enum case, myschema.blah_ops is/was being delimited as "myschema.blah_ops" instead of "myschema"."blah_ops".

@khellang
Copy link
Copy Markdown
Contributor Author

For example, in the enum case, myschema.blah_ops is/was being delimited as "myschema.blah_ops" instead of "myschema"."blah_ops".

Ah, yeah, that's probably happening here as well, unless SqlGenerationHelper.DelimitIdentifier handles schema-qualified identifiers? I'll take a look.

@khellang
Copy link
Copy Markdown
Contributor Author

OK, I think the schema-qualified case should be handled now 👍

@austindrenski
Copy link
Copy Markdown
Contributor

That looks great! Thanks for making those changes and the additional unit test.

@roji @YohDeadfall Could one of you give this a second review?

Comment thread src/EFCore.PG/Metadata/INpgsqlIndexAnnotations.cs Outdated
Comment thread src/EFCore.PG/Metadata/NpgsqlIndexAnnotations.cs
Comment thread src/EFCore.PG/Utilities/Check.cs
Copy link
Copy Markdown
Contributor

@austindrenski austindrenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more questions regarding string[]/IReadOnlyList<string>.

Comment thread src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs
Comment thread src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs
Comment thread src/EFCore.PG/Metadata/NpgsqlIndexAnnotations.cs
@austindrenski austindrenski added this to the 2.2.0 milestone Oct 19, 2018
@austindrenski
Copy link
Copy Markdown
Contributor

@roji Did you want to give this a look before the merge?

@austindrenski
Copy link
Copy Markdown
Contributor

@khellang Would you mind rebasing?

@khellang
Copy link
Copy Markdown
Contributor Author

@austindrenski Done! ✨

@austindrenski
Copy link
Copy Markdown
Contributor

@khellang Thanks!

@roji Do you have time today to give this a quick review?

Copy link
Copy Markdown
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for the quality work and the reviewing!

@austindrenski you can go ahead and merge.

@austindrenski austindrenski merged commit 10fb80e into npgsql:dev Nov 14, 2018
@khellang khellang deleted the index-operators branch November 14, 2018 19:11
roji added a commit to roji/efcore.pg that referenced this pull request Nov 17, 2018
roji added a commit to roji/efcore.pg that referenced this pull request Nov 17, 2018
roji added a commit that referenced this pull request Nov 17, 2018
austindrenski pushed a commit to austindrenski/npgsql-efcore.pg that referenced this pull request Nov 18, 2018
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.

4 participants