Skip to content

NH-4065 - MsSql Dialect + ODBC, mapping an nvarchar(max) using string(10000) causes string truncation #1360

Closed
@nhibernate-bot

Description

@nhibernate-bot

Alessandro Giorgetti created an issue — 4th August 2017, 17:48:29:

The NH-2302 fixed has forgot about Odbc and MsSqlCe, which had also been impacted by the seemingly rogue change "set param len" for optimizing query plan cache usage. (Commit 03eb58acae867e2d5620446c3b07cb91e7d74422.) Below is the NH-2302 description.

In NHibernate 2.1 we were used to map nvarchar(max) columns using something like this:

<property name="propertyname" column="columnname" type="string" length="10000" />

When using SchemaExport() this mapping correctly generates a nvarchar(max) column, but when reading and writing to the column the text is truncated to the size limit of the length specified in the mapping (10k chars in this care): if I try to store a string whose length is 12k chars I get back a 10k chars string.

Using a StringClob mapping and specifying the correct sql-type (like in the following snippet) seems to resolve the problem:

<property name="BlobSqlType" type="StringClob" >
      <column name="BlobSqlType" sql-type="nvarchar(max)" />
</property>

Any other combination I've tried doesn't seem to work. This will introduce an unwanted dependency in the mappings and will force us to review all the mappings in our project if we want to switch over to NHibernate 3


Frédéric Delaporte added a comment — 4th August 2017, 17:54:53:

NH-2302 was fixed with this commit, probably doable likewise with ODBC and MsSqlCe. But ODBC may be used for other databases:

  • Does it makes sense to set parameter lengths for those other databases?
  • Could the SQL Server case fix cause trouble for them otherwise?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions