Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 159c88e

Browse files
committed
fix Normalize Schema
1 parent d3d9872 commit 159c88e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ServiceStack.OrmLite.PostgreSQL/PostgreSQLDialectProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,11 @@ public override bool DoesTableExist(IDbCommand dbCmd, string tableName, string s
273273

274274
// If a search path (schema) is specified, and there is only one, then assume the CREATE TABLE directive should apply to that schema.
275275
if (!string.IsNullOrEmpty(schema) && !schema.Contains(","))
276+
{
276277
sql = !Normalize
277278
? "SELECT COUNT(*) FROM pg_class JOIN pg_catalog.pg_namespace n ON n.oid = pg_class.relnamespace WHERE relname = {0} AND nspname = {1}".SqlFmt(tableName, schema)
278279
: "SELECT COUNT(*) FROM pg_class JOIN pg_catalog.pg_namespace n ON n.oid = pg_class.relnamespace WHERE lower(relname) = {0} AND lower(nspname) = {1}".SqlFmt(tableName.ToLower(), schema.ToLower());
280+
}
279281
}
280282

281283
var result = dbCmd.ExecLongScalar(sql);
@@ -295,7 +297,7 @@ public override bool DoesColumnExist(IDbConnection db, string columnName, string
295297
? " AND TABLE_SCHEMA = @schema"
296298
: " AND lower(TABLE_SCHEMA) = @schema";
297299

298-
if (!Normalize)
300+
if (Normalize)
299301
schema = schema.ToLower();
300302
}
301303

@@ -347,7 +349,7 @@ public override string GetQuotedTableName(ModelDefinition modelDef)
347349
{
348350
if (!modelDef.IsInSchema)
349351
return base.GetQuotedTableName(modelDef);
350-
if (!Normalize && !ReservedWords.Contains(modelDef.ModelName) && !ReservedWords.Contains(modelDef.Schema))
352+
if (Normalize && !ReservedWords.Contains(modelDef.ModelName) && !ReservedWords.Contains(modelDef.Schema))
351353
return modelDef.Schema + "." + base.NamingStrategy.GetTableName(modelDef.ModelName);
352354

353355
string escapedSchema = modelDef.Schema.Replace(".", "\".\"");

0 commit comments

Comments
 (0)