[odb-users] Queries matching on NVARCHAR fields fail to return records when using "short data"

Boris Kolpackov boris at codesynthesis.com
Fri Oct 5 05:08:07 EDT 2012

Hi Oded,

Oded Arbel <oded at geek.co.il> writes:

> I'm using MS-SQL Server 2008, and I noticed that when I use queries
> that match on NVARCHAR fields, the matching always fails if the field
> is short enough to be considered "short data" (according to section
> 17.1 of the manual).

I've done some testing and found the bug. It only affects short data
national characters. I've prepared the libodb-mssql-2.1.1 bugfix:


Can you give it a try and confirm it works for you. Then I will
publish it as an official bugfix release.

> My model class looks something like this:
> typedef std::wstring short_string;
> #pragma db value(short_string) type("NVARCHAR(36)")
> typedef std::wstring long_text;
> #pragma db value(long_text) type("NVARCHAR(MAX)")

Unfortunately, this won't work since typedef does not create a new
type, just another name for the same one. So with the above fragment
any std::wstring, short_string, or long_text data member that doesn't
specify the type explicitly will default to NVARCHAR(MAX).


More information about the odb-users mailing list