Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use grate on UTF-8 collations #591

Open
SamuelMcAravey opened this issue Oct 23, 2024 · 1 comment
Open

Unable to use grate on UTF-8 collations #591

SamuelMcAravey opened this issue Oct 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@SamuelMcAravey
Copy link

Describe the bug
Unable to use UTF-8 collations with SQL Server due to using the obsolete text column type.

To Reproduce
Create a new database using a UTF-8 collation, such as Latin1_General_100_CI_AS_SC_UTF8, and run grate against this database.

Expected behavior
A successful migration happens.

Screenshots

image

Desktop (please complete the following information):

  • OS: Windows
  • Version: 1.8.0

Additional context
When running this through the debugger, I get this specific exception which indicates that this is due to the text type:

'Column or parameter 'text_of_script' has type 'text' and collation 'Latin1_General_100_CI_AS_SC_UTF8'.
The legacy LOB types do not support UTF-8 or UTF-16 encodings. 
Use types varchar(max), nvarchar(max) or a collation which does not have the _SC or _UTF8 flags.'

In my local version I changed all of the text types to nvarchar(max) and everything functioned as expected.

There appears to have been some prior discussion here, but it appears that the column type was not updated:
#250

@erikbra
Copy link
Owner

erikbra commented Jan 19, 2025

Actually, this is fixed, but in an update script, so it looks like it doesn't work if it's not possible to create a column with text type at all, when running for the first time.

We need to think about how we can ensure that the Baseline scripts can actually be run the first time too, without trying to run them twice (if we change them). Good ideas and PRs are appreciated.

We do alter the type of the columns in a migration afterwards:

https://github.com/erikbra/grate/blob/main/src/grate.sqlserver/Bootstrapping/Sql/GrateStructure/up/03_scripts_run_errors_unicode_support.sql

@erikbra erikbra added the bug Something isn't working label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants