Skip to content

Actual bound on infinite NpgsqlRange shouldn't affect equality #1418

Closed

Description

@kurtschelfthout

Steps to reproduce

var r1 = new NpgsqlRange<int>(0, true, false, 10, false, true);
var r2 = new NpgsqlRange<int>(0, true, false, 11, false, true);
r1.Equals(r2); // false

The issue

The upper bound of both ranges is infinite, but the ctor forces use to input an arbitrary upper bound anyway. I submit that the value of a bound should be ignored when it is infinite. And so the above example should return true.

There may be other places where the actual value influences the result of operations where it shouldn't.

Further technical details

Not relevant for this issue.

Activity

  1. roji commented on Jan 30, 2017

    @roji
    Member

    You're right. The equality comparer should definitely be fixed: if a bound is infinite, then neither its inclusiveness or its actual value be compared. Would you like to submit a PR on this, including testing?

    It's true that it would be nice to have a constructor that doesn't force you to pass a value if the bound is infinite, but it seems that with all the different options the constructors could get pretty complicated and confusing. If you have good ideas on this I'm interested too.

  2. added this to the 3.2.1 milestone on Jan 30, 2017
  3. kurtschelfthout commented on Jan 31, 2017

    @kurtschelfthout
    ContributorAuthor

    Yes, I can take a look at this.

  4. roji commented on Feb 10, 2017

    @roji
    Member

    @kurtschelfthout, any chance you can spare the time to do this? I intend to release 3.2.1 sometime this week, it would be good to include it.

  5. kurtschelfthout commented on Feb 12, 2017

    @kurtschelfthout
    ContributorAuthor

    I tried to but kind of failed at the first hurdle - VS 2015 Community edition couldn't open any of the projects. Is that expected? E.g. Npgsql failed with:

    src\Npgsql\Npgsql.csproj : error : The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format. C:\Users\Kurt\Projects\npgsql\src\Npgsql\Npgsql.csproj

  6. roji commented on Feb 12, 2017

    @roji
    Member

    Yep... Npgsql 3.2.0 uses a C# 7.0, which required me to transition the project to the new SDK and VS2017. The 2017RC is pretty stable so you may want to work with that, or you can just download the latest dotnet CLI and work on the commandline.

  7. roji commented on Feb 12, 2017

    @roji
    Member

    FYI I'd really like to release 3.2.1 tomorrow, hopefully you can get around to doing this by then...

  8. kurtschelfthout commented on Feb 12, 2017

    @kurtschelfthout
    ContributorAuthor

    Probably won't make that, sorry.

  9. modified the milestones: 3.2.1, 3.2.2 on Feb 14, 2017
  10. kurtschelfthout commented on Feb 16, 2017

    @kurtschelfthout
    ContributorAuthor

    So I now tried build.ps1, which fails with the below. Is the only option really installing 2017 RC? I also noticed it defaults to the dev branch, is that ok?

    Sorry for the 20 questions. Do you have a contributing guide that I totally missed?

    PS C:\Users\Kurt\Projects\npgsql> .\build.ps1
    Building C:\Users\Kurt\Projects\npgsql
    dotnet-install: .NET SDK version 1.0.0-preview2-003131 is already installed.
    Adding C:\Users\Kurt\AppData\Local\Microsoft\dotnet\ to PATH
    Using makefile: .build\shade\makefile.shade
    info: Run target: default
    info: Run target: pre-clean
    info: Run target: target-dir-clean
    info: Run target: clean
    info: Run target: post-clean
    info: Run target: validate
    info: Run target: restore-npm-modules
    info: Run target: restore-bower-components
    info: Run target: run-grunt
    info: Run target: repo-initialize
    info: Exec
    info:   program: dotnet
    info:   commandline: restore
    info:   workingdir: C:\Users\Kurt\Projects\npgsql
    warn : The folder 'C:\Users\Kurt\Projects\npgsql' does not contain a project to restore.
    info: Run target: initialize
    info: Run target: build-compile
    info:
    info: Exec
    info:   program: dotnet
    info:   commandline: build  src/*/project.json test/*/project.json --configuration Debug
    info:   workingdir: C:\Users\Kurt\Projects\npgsql
    Globbing pattern 'src/*/project.json' did not match any files
    fail: Exit code 1 from dotnet
    fail: Stack trace:
       at View7be9f32c76f3461aa7caa3e66706f4ee.Dotnet(String command) in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 1072
       at View7be9f32c76f3461aa7caa3e66706f4ee.DotnetBuild(String projectFile, String configuration, String framework) in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 1309
       at View7be9f32c76f3461aa7caa3e66706f4ee.<>c__DisplayClasse8.<RenderViewLevel0>b__ac() in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 9586
       at Sake.Engine.Builder.BuilderBase`1.CallTarget(String name)
       at Sake.Engine.Builder.BuilderBase`1.StartingTarget(String name)
       at View7be9f32c76f3461aa7caa3e66706f4ee.StartingTarget(String name) in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 3594
       at View7be9f32c76f3461aa7caa3e66706f4ee.<RenderViewLevel0>b__64() in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 4041
       at Sake.Engine.Builder.BuilderBase`1.CallTarget(String name)
       at Sake.Engine.Builder.BuilderBase`1.StartingTarget(String name)
       at View7be9f32c76f3461aa7caa3e66706f4ee.StartingTarget(String name) in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 3594
       at View7be9f32c76f3461aa7caa3e66706f4ee.<RenderViewLevel0>b__65() in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 4058
       at Sake.Engine.Builder.BuilderBase`1.CallTarget(String name)
       at Sake.Engine.Builder.BuilderBase`1.StartingTarget(String name)
       at View7be9f32c76f3461aa7caa3e66706f4ee.StartingTarget(String name) in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 3594
       at View7be9f32c76f3461aa7caa3e66706f4ee.<RenderViewLevel0>b__66() in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 4075
       at Sake.Engine.Builder.BuilderBase`1.CallTarget(String name)
       at View7be9f32c76f3461aa7caa3e66706f4ee.<RenderViewLevel0>b__5e() in c:\Users\Kurt\AppData\Local\Temp\94afee57ca3849c4975755eb9f1fdd68-1.cs:line 3931
       at Sake.Engine.Builder.BuilderBase`1.CallTarget(String name)
       at Sake.Engine.SakeEngine.Execute(Options options)
       at Sake.Engine.SakeEngine.Execute(String[] args)
       at Sake.Program.Main(String[] args)
    
  11. kurtschelfthout commented on Feb 16, 2017

    @kurtschelfthout
    ContributorAuthor

    On making the constructor a bit nicer to use. I suggest to introduce a separate Bound<T> type with two factory methods: Bound.Infinite and Bound.Value<T>(T t, bool isInclusive). The basic range ctor would be new NpgsqlRange<T>(Bound<T> lower, Bound<T> upper). A convenience ctor like new NpgsqlRange<T>(T lower, T upper) for finite, inclusive ranges can still be retained.

    This makes several bad states effectively not possible by design: you can't make an infinite bound that is inclusive. You can't provide a value for an infinite bound. It is perhaps slightly more verbose but more readable, compare new NpgsqlRange<int>(0, true, false, 10, false, true) with new NpgsqlRange<int>(Bound.Value(0, true), Bound.Infinite)

    I assume you use semantic versioning or some such - the existing ctors could just be rewritten in terms of this, and marked obsolete.

  12. roji commented on Feb 16, 2017

    @roji
    Member

    Regarding the build, Microsoft tooling is changing a lot at the moment and it's messy indeed. The ps1 isn't really supposed to work. VS2017 RTMs on March 7th, at which point everything should calm down. If you don't want to install VS2017RC, you can build with the latest dotnet cli from here.

    Gotta go now, but will look at your ctor proposal soon.

  13. added a commit that references this issue on Mar 19, 2017
    c3109f9
  14. added theissue type on Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions