-
Notifications
You must be signed in to change notification settings - Fork 261
Translate bytea.Any() as length > 0
#3817
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
Changes from 5 commits
8b793ef
403572f
f9b705e
e995de3
05db0b8
eaf214f
e2ad4b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; | ||
|
|
||
| namespace Microsoft.EntityFrameworkCore.Query.Translations; | ||
|
|
||
| public class ByteArrayTranslationsNpgsqlTest : ByteArrayTranslationsTestBase<BasicTypesQueryNpgsqlFixture> | ||
|
|
@@ -98,6 +100,32 @@ public override async Task SequenceEqual() | |
| """); | ||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public virtual async Task Length_greater_than_zero() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think this test is necessary, given that we already have coverage for Length and Any? This tests a composite tree pattern (so both ByteArray.Length and greater-than-zero), but we usually do that only when there's a special casing - here it seems like it's just the regular translation for Length, and then the regular translation for greater-than-zero. Another way to think about it, is that AFAICT this doesn't add any more coverage than Length_greater_than_one, Length_greater_than_two would (and obviously we wouldn't do them). (I understand that we now normalize So unless you think there's a specific reason for this test, we can consider removing it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw #3817 (comment) - I'm still not sure that test really adds anything, but I'm also OK with leaving it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. I agree that one of them is sufficient to cover the relevant code paths, so I removed the Length > 0 test in e2ad4b0 |
||
| { | ||
| await AssertQuery(ss => ss.Set<BasicTypesEntity>().Where(e => e.ByteArray.Length > 0)); | ||
|
|
||
| AssertSql( | ||
| """ | ||
| SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
| FROM "BasicTypesEntities" AS b | ||
| WHERE length(b."ByteArray") > 0 | ||
| """); | ||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public virtual async Task Any() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW I'll "promote" this test to the EF test suite later as it's not very PG-specific. |
||
| { | ||
| await AssertQuery(ss => ss.Set<BasicTypesEntity>().Where(e => e.ByteArray.Any())); | ||
|
|
||
| AssertSql( | ||
| """ | ||
| SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" | ||
| FROM "BasicTypesEntities" AS b | ||
| WHERE length(b."ByteArray") > 0 | ||
| """); | ||
| } | ||
|
|
||
| private void AssertSql(params string[] expected) | ||
| => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.