-
Notifications
You must be signed in to change notification settings - Fork 471
Support Guid ToString in all databases, add test for all DBs #4297
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a58e427
Support Guid ToString in SqLite, add test for mssql and sqlite
jogibear9988 b920c94
Rename GuidToString to GuidToNormalizedString and change test
jogibear9988 d4221cd
fix other providers
jogibear9988 ff1efb0
fix other providers
jogibear9988 5d304d8
Update Source/LinqToDB/Sql/Sql.cs
jogibear9988 37f0f47
fix NotNullIfNotNull usage
jogibear9988 7136225
add sqlserver, switch to lowercase (like to more)
jogibear9988 094557f
fix maria db in linq2db6
jogibear9988 1cd8099
fix compile in linqdb6
jogibear9988 38e4191
add to lower
jogibear9988 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System.Linq; | ||
using FluentAssertions; | ||
using LinqToDB; | ||
using LinqToDB.Mapping; | ||
using NUnit.Framework; | ||
using System.Linq.Dynamic.Core; | ||
using System.Linq.Dynamic.Core.CustomTypeProviders; | ||
using System.Collections.Generic; | ||
using System; | ||
using LinqToDB.Data; | ||
|
||
namespace Tests.UserTests | ||
{ | ||
[TestFixture] | ||
public class Issue4295Tests : TestBase | ||
{ | ||
[Table] | ||
public class InfeedAdvicePositionDTO | ||
{ | ||
[Column] public Guid Id { get; set; } | ||
} | ||
|
||
[Test] | ||
public void TestGuidToString([DataSources] string context) | ||
{ | ||
using (var db = GetDataContext(context)) | ||
using (db.CreateLocalTable<InfeedAdvicePositionDTO>()) | ||
{ | ||
var expected = "193AE7F4-5309-4EEE-A746-27B28C7E30F3".ToLowerInvariant(); | ||
|
||
var a = new InfeedAdvicePositionDTO() { Id = Guid.Parse(expected) }; | ||
db.Insert(a); | ||
|
||
var id = (from infeed in db.GetTable<InfeedAdvicePositionDTO>() | ||
select Sql.GuidToNormalizedString(infeed.Id)).First(); | ||
|
||
Assert.That(id, Is.EqualTo(expected)); | ||
|
||
var qryA = from infeed in db.GetTable<InfeedAdvicePositionDTO>() | ||
where Sql.GuidToNormalizedString(infeed.Id)!.Contains("7f4-53") | ||
select infeed; | ||
|
||
var lA = qryA.ToList(); | ||
Assert.That(lA, Has.Count.EqualTo(1)); | ||
|
||
var qryB = from infeed in db.GetTable<InfeedAdvicePositionDTO>() | ||
where Sql.GuidToNormalizedString(infeed.Id)!.StartsWith("193ae") | ||
select infeed; | ||
|
||
var lB = qryB.ToList(); | ||
Assert.That(lB, Has.Count.EqualTo(1)); | ||
|
||
|
||
var qryC = from infeed in db.GetTable<InfeedAdvicePositionDTO>() | ||
where Sql.GuidToNormalizedString(infeed.Id)!.Contains("8f4-53") | ||
select infeed; | ||
|
||
var lC = qryC.ToList(); | ||
Assert.That(lC, Has.Count.EqualTo(0)); | ||
|
||
var qryD = from infeed in db.GetTable<InfeedAdvicePositionDTO>() | ||
where Sql.GuidToNormalizedString(infeed.Id)!.ToLower().StartsWith("293ae") | ||
select infeed; | ||
|
||
var lD = qryD.ToList(); | ||
Assert.That(lD, Has.Count.EqualTo(0)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.