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

Grate is applying a case-sensitive comparison to Schema name in a case-insensitive SQL Server. #230

Open
wokket opened this issue Sep 2, 2022 · 4 comments

Comments

@wokket
Copy link
Collaborator

wokket commented Sep 2, 2022

I'm migrating an existing RH db over to grate (on a case-insensitive SQL 2019 server), and when migrated with grate --schema=roundhouse [other options elided] it fails with:

Unhandled exception: Microsoft.Data.SqlClient.SqlException (0x80131904): There is already an object named 'roundhouse' in the database.
CREATE SCHEMA failed due to previous errors.
   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.SqlCommand.InternalEndExecuteNonQuery(IAsyncResult asyncResult, Boolean isInternal, String endMethod)
   at Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(IAsyncResult asyncResult)
   at Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location ---
   at grate.Migration.AnsiSqlDatabase.ExecuteNonQuery(DbConnection conn, String sql, Nullable`1 timeout) in /home/runner/work/grate/grate/grate/Migration/AnsiSqlDatabase.cs:line 664
   at grate.Migration.AnsiSqlDatabase.ExecuteNonQuery(DbConnection conn, String sql, Nullable`1 timeout) in /home/runner/work/grate/grate/grate/Migration/AnsiSqlDatabase.cs:line 664
   at grate.Migration.AnsiSqlDatabase.CreateRunSchema() in /home/runner/work/grate/grate/grate/Migration/AnsiSqlDatabase.cs:line 251
   at grate.Migration.AnsiSqlDatabase.RunSupportTasks() in /home/runner/work/grate/grate/grate/Migration/AnsiSqlDatabase.cs:line 240
   at grate.Migration.GrateMigrator.CreateGrateStructure(IDbMigrator dbMigrator) in /home/runner/work/grate/grate/grate/Migration/GrateMigrator.cs:line 212
   at grate.Migration.GrateMigrator.Migrate() in /home/runner/work/grate/grate/grate/Migration/GrateMigrator.cs:line 85
   at grate.Commands.MigrateCommand.<>c__DisplayClass0_0.<<-ctor>b__0>d.MoveNext() in /home/runner/work/grate/grate/grate/Commands/MigrateCommand.cs:line 48

Correcting the script to grate --schema=RoundhousE [other options elided] works correctly.

Desktop (please complete the following information):

  • OS: Windows 11
  • Version 1.3 and 1.4
@erikbra
Copy link
Owner

erikbra commented Sep 2, 2022

Do you know if this is a new error/regression in 1.3, @wokket? or do you think it was always there?

@wokket
Copy link
Collaborator Author

wokket commented Sep 2, 2022

I'm not sure, I haven't gone back looking at earlier versions but can if you'd like. This is the first RH project I've moved to grate.

wokket added a commit to wokket/grate that referenced this issue Sep 6, 2022
wokket added a commit to wokket/grate that referenced this issue Sep 6, 2022
wokket added a commit to wokket/grate that referenced this issue Sep 6, 2022
@wokket wokket linked a pull request Sep 6, 2022 that will close this issue
@erikbra
Copy link
Owner

erikbra commented Sep 20, 2022

A thought which I had when thinking about casing in PostgreSQL schemas and tables, would this work for SQL server too?

#245 (comment)

@wokket
Copy link
Collaborator Author

wokket commented Sep 23, 2022

I'm not in a position to really think through the repercussions there, but I added a test in my PR that you could use in another branch to see if it sorts the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants