#1 2026-11-04 22:01:53

PixelNaut_78
Member
Registered: 2026-11-04
Posts: 1

mORMot 1: Force a specific field to be VARCHAR (instead of NVARCHAR)

Hi everyone,

I am working with mORMot 1 and MS SQL Server. When using `CreateMissingTables` (or the ORM schema generation), string properties are mapped by default to `NVARCHAR` globally.

This makes total sense since Unicode is standard, and `VARCHAR` is mostly deprecated for general text. However, I have a specific scenario where a legacy external software reads these tables and strictly requires UUID fields to be stored as standard `VARCHAR` (non-Unicode) instead of `NVARCHAR`.

I inspected the mORMot source code to see if a string field type could be overridden / set in the model definition, but the properties/types seem read-only or tightly bound to the global MS SQL driver mapping.

Currently, our workaround is running a post-creation script with an `ALTER TABLE ... ALTER COLUMN` to change those specific UUID columns from `NVARCHAR` to `VARCHAR`.

Is there a built-in way in mORMot 1 to declare a specific string property as an ANSI `VARCHAR` column during table creation, or is post-scripting via `ALTER` the recommended approach for this kind of legacy integration?

Thanks in advance!

Offline

#2 2026-11-05 01:31:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,629
Website

Re: mORMot 1: Force a specific field to be VARCHAR (instead of NVARCHAR)

The easiest is to make the CREATE TABLE statement yourself instead of calling CreateMissingTables. wink

Offline

Board footer

Powered by FluxBB