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

fix #230: Fix schema (in)sensitive casing issue #234

Closed
wants to merge 3 commits into from

Conversation

wokket
Copy link
Collaborator

@wokket wokket commented Sep 6, 2022

Had some merge issues but think I'm there.

Assorted changes to DBMS's that are (generally) case insensitive.

PGSql is a little interesting with case-sensitive tables but case insensitive schemas (as currently implemented), but so be it.

There's possibly an option to bypass the Exists checks entirely for those DBMS's that support create table if not exists syntax, but that's a bridge too far for me time-wise atm.

@@ -256,7 +256,7 @@ private async Task<bool> RunSchemaExists()
{
string sql = $"SELECT s.schema_name FROM information_schema.schemata s WHERE s.schema_name = '{SchemaName}'";
var res = await ExecuteScalarAsync<string>(ActiveConnection, sql);
return res == SchemaName;
return res != null; // #230: If the server found a record that's good enough for us
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be null, or can it be DBNull?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK handling the DBNull returned from the sql client is Dapper's job, and it converts to either null or default() depending on the type it's trying to map to.

If you have any info to the contrary I'd be very keen to know about it!

@wokket
Copy link
Collaborator Author

wokket commented Jun 3, 2023

G'day @erikbra , just wondering if there's anything holding up this fix from your side? I tried to convert another existing Roundhouse/SQL server project to grate recently and still have to force v1.3.2 to get it to work... Hoping this and a few other fixes will get me closer to the line

@erikbra
Copy link
Owner

erikbra commented Jun 3, 2023

Hi, @wokket - thanks for being patient. No, nothing other than myself holding this up (but that is a big enough hurdle by itself sometimes). I resolved some merge conflicts, and I'm waiting for the tests to run, and I'm ready to merge if they run as they should.

It's been hard to prioritise a lot of time on grate the last months, sorry.

@erikbra
Copy link
Owner

erikbra commented Jun 3, 2023

Seems like tests are failing on MariaDB and SqlServer, unfortunately, @wokket

@wokket
Copy link
Collaborator Author

wokket commented Jun 5, 2023

Probably not surprising after nearly 9 months 🤣

I'll try and see what's going on when I get a chance... I definitely feel like focussing on closing out some of these bugs/weirdness/idiosyncrasies that have crept in is a good thing.

…spect the failing tests indicate the bug is still present on other DBMS's, but I don't know enough to go chasing that right now.
@wokket wokket force-pushed the feat/#230-schema-casing-MkII branch from f0f34c0 to 973fc48 Compare June 8, 2023 05:24
@wokket
Copy link
Collaborator Author

wokket commented Jun 8, 2023

OK, after fighting with inconsistent test runs locally for a few hours I think we still have some stuff to sort out here.

In the current main codebase, we are still applying a case-sensitive check for whether the grate schema exists, regardless of server casing rules, so #230 is still in play :(

The new check for whether a table (like Version) exists is now applying a case-_in_sensitive search, regardless of server casing rules, which means the scenario I'm testing here (run a migration against a schema, then again a second time with different casing, replicating what we did to try and upgrade our roundhouse project to grate) fails because the exists check for Version says it exists, but all the following uses of the table fail as it can't find the table as passed-in.

Do we want to change the table exists checks to return both the schema and table as found in the database and use that for the rest of the migration?

I understand the case-insensitive lookups as a workaround for bug #245, and keeping back-compat with existing database already migrated is obviously paramount, but it feels like forcing case insensitivity in some places, and respecting the target casing rules are fundamentally incompatible :(

@cocytus
Copy link

cocytus commented Nov 30, 2023

Related: After one year, I don't think i issue #245 is actually fixed for postgres. I tried the latest 1.5.4 release, and exactly as a year ago, grate creates "ScriptsRun[Error]" and "Version" tables, even though "scriptsrun" and "version" exists.

@erikbra
Copy link
Owner

erikbra commented Jul 22, 2024

This one should be solved by. other means now :)

@erikbra erikbra closed this Jul 22, 2024
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 this pull request may close these issues.

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