GetQuotedTableName does not honor naming strategy for schema

The schema is taken from modelDef.Schema, but it should use NamingStrategy.GetSchemaName(modelDef.Schema). Below an updated version that does this.

public override string GetQuotedTableName(ModelDefinition modelDef)
{
  if (!modelDef.IsInSchema)
    return base.GetQuotedTableName(modelDef);
  if (Normalize && !ReservedWords.Contains(modelDef.ModelName) && !ReservedWords.Contains(modelDef.Schema))
    return NamingStrategy.GetSchemaName(modelDef.Schema) + "." + NamingStrategy.GetTableName(modelDef.ModelName);

  string escapedSchema = NamingStrategy.GetSchemaName(modelDef.Schema).Replace(".", "\".\"");
  return $ "\"{escapedSchema}\".\"{NamingStrategy.GetTableName(modelDef.ModelName)}\"";
}

(I had to include a space between de $ and the rest of the escapedSchema, since it would generate a GUID instead)

Added in this commit this change is available from v5.4.1 that’s now on MyGet.

1 Like