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

SQLite Scaffolding: Reverse engineer collation #29857

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ ORDER BY "cid"

_logger.ColumnFound(table.Name, columnName, dataType, notNull, defaultValue);

string? collation = null;
var autoIncrement = 0;
if (connection is SqliteConnection sqliteConnection
&& !(table is DatabaseView))
Expand All @@ -241,7 +242,7 @@ ORDER BY "cid"
table.Name,
columnName,
out _,
out _,
out collation,
out _,
out _,
out autoIncrement);
Expand All @@ -264,7 +265,10 @@ ORDER BY "cid"
: string.Empty,
IsStored = hidden != 3L
? default(bool?)
: true
: true,
Collation = string.Equals(collation, "BINARY", StringComparison.OrdinalIgnoreCase)
? null
: collation
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,26 @@ CREATE TABLE AutoIncTest (
},
"DROP TABLE AutoIncTest");

[ConditionalFact]
public void Column_collation_is_set()
=> Test(
@"
CREATE TABLE ColumnsWithCollation (
Id int,
DefaultCollation text,
NonDefaultCollation text COLLATE NOCASE
);",
Enumerable.Empty<string>(),
Enumerable.Empty<string>(),
dbModel =>
{
var columns = dbModel.Tables.Single().Columns;

Assert.Null(columns.Single(c => c.Name == "DefaultCollation").Collation);
Assert.Equal("NOCASE", columns.Single(c => c.Name == "NonDefaultCollation").Collation);
},
"DROP TABLE ColumnsWithCollation;");

#endregion

#region PrimaryKeyFacets
Expand Down