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

Oded Arbel oded at geek.co.il
Sun Oct 7 05:34:00 EDT 2012


On Fri, Oct 5, 2012 at 11:08 AM, Boris Kolpackov <boris at codesynthesis.com>wrote:

> 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:
>

Thanks for the quick turnaround! Unfortunately we're still working with
2.0, and at this point I'd rather not upgrade to 2.1 (I may be able to push
to 2.1 later this year). In the mean time, is it possible for you to push
this as a bugfix on 2.0? TIA


> 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).
>

>From the use of #pragma db value() in the manual, I understood that this
use is OK (though it doesn't state that specifically). Interesting though
that with the setting I specified in my previous email ( short-limit=100),
selecting on a field defined as "long_text" succeeds while selecting on a
field defined as "short_string" fails (none of which specify #pragma db
type specifically in the class decleration) - so it looks like there is
some difference in how ODB treats these typedefs - unless it has something
to do with the long_text field being actually odb::nullable<long_text>?

Best regards,
-- 
Oded


More information about the odb-users mailing list