Skip to content

Commit 324d9fa

Browse files
authored
Fix enum scaffolding for PG < 9.1 (#2162)
Fixes #2160
1 parent 0d227b3 commit 324d9fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,11 @@ AND NOT EXISTS (SELECT * FROM pg_depend AS dep WHERE dep.objid = cls.oid AND dep
986986
/// </summary>
987987
private static HashSet<string> GetEnums(NpgsqlConnection connection, DatabaseModel databaseModel)
988988
{
989-
const string commandText = @"
989+
var commandText = $@"
990990
SELECT
991991
nspname,
992992
typname,
993-
array_agg(enumlabel ORDER BY enumsortorder) AS labels
993+
array_agg(enumlabel{(connection.PostgreSqlVersion >= new Version(9, 1) ? " ORDER BY enumsortorder" : "")}) AS labels
994994
FROM pg_enum
995995
JOIN pg_type ON pg_type.oid = enumtypid
996996
JOIN pg_namespace ON pg_namespace.oid = pg_type.typnamespace

0 commit comments

Comments
 (0)