提交 7d5d7fe0 编写于 作者: S Shay Rojansky

Fix migration history table lookup (#2788)

(cherry picked from commit 9418c25e)
上级 e5ade7f0
......@@ -16,26 +16,15 @@ protected override string ExistsSql
{
get
{
var builder = new StringBuilder();
builder.Append("SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE ");
var stringTypeMapping = Dependencies.TypeMappingSource.GetMapping(typeof(string));
if (TableSchema is not null)
{
builder
.Append("n.nspname=")
.Append(stringTypeMapping.GenerateSqlLiteral(TableSchema))
.Append(" AND ");
}
builder
.Append("c.relname=")
.Append(stringTypeMapping.GenerateSqlLiteral(TableName))
.Append(");");
return builder.ToString();
return $@"
SELECT EXISTS (
SELECT 1 FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
WHERE n.nspname={stringTypeMapping.GenerateSqlLiteral(TableSchema ?? "public")} AND
c.relname={stringTypeMapping.GenerateSqlLiteral(TableName)}
)";
}
}
......@@ -60,4 +49,4 @@ public override string GetCreateIfNotExistsScript()
public override string GetEndIfScript() =>
@" END IF;
END $EF$;";
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册