invalid cast to int in generated sql with a char property

Description

a class with a char property
public class User
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual char Type { get; set; }
}

and this query

var user = s.Query<User>().Where(x => x.Type == 'A').ToList();

generate incorrect sql with a cast to int

select user0_.UserId as UserId0_, user0_.Name as Name0_, user0_.Type as Type0_ from [User] user0_ where cast(user0_.Type as INT)=@p0
Name1 - Value:65

Environment

None

Attachments

1
  • 22 Apr 2012, 10:14 PM

Activity

Show:

Alex Zaytsev August 2, 2012 at 8:54 AM

Closed after NH 3.3.1.GA release

Alex Zaytsev May 23, 2012 at 7:56 PM

Applied to 3.3.x

Julian Maughan May 6, 2012 at 3:44 PM

Here is a proposal to fix the problem: https://github.com/nhibernate/nhibernate-core/pull/99

Alex Zaytsev April 24, 2012 at 5:34 PM

Using Equals solves the problem:

session.Query<Person>().Where(x => 'A'.Equals(x.Type)).ToList();

Oskar Berggren April 23, 2012 at 7:38 PM

Regressed in ed14368e1a1b0b98cf08543593eb05bb611695e0 from 2012-03-10.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created April 22, 2012 at 10:14 PM
Updated July 2, 2015 at 11:51 PM
Resolved May 23, 2012 at 7:56 PM
Who's Looking?