Skip to content

Comparison with DateTime? produces wrong SQL #1468

Closed
@andyci

Description

@andyci

Hi,

Namespace Issues

    Namespace NA

        Public Class Entity

            Private _id As Guid
            Public Overridable Property Id() As Guid
                Get
                    Return _id
                End Get
                Set(ByVal value As Guid)
                    _id = value
                End Set
            End Property

            Private _date1 As Date?
            Public Overridable Property Date1() As Date?
                Get
                    Return _date1
                End Get
                Set(ByVal value As Date?)
                    _date1 = value
                End Set
            End Property


        End Class

    End Namespace

End Namespace
Using session As ISession = OpenSession()
    Dim d = New Date(2017, 12, 2)
    Dim result = (From e In session.Query(Of Entity)()
    Where e.Date1 >= d
    Select e).ToList()
    Assert.AreEqual(0, result.Count)
End Using

produces the following strange SQL:

[ select entity0_.Id as id1_0_, entity0_.Date1 as date2_0_
    from Entity entity0_
    where coalesce(entity0_.Date1>=@p0, @p1)=1 ]
  Name:p1 - Value:02/12/2017 00:00:00  Name:p2 - Value:False

Not sure if this is VB specific or whether it happens in C# as well.

Tested on NHibernate 5.0.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions