robconery/massive — Issue #115: Postgres version is using TOP instead of LIMIT and wants some hugs
Author: DataChomp
Created: 2011-12-06 01:23:42+00:00
State: open

The use of Top + limit doesn't work so hot in postgres. Modified to use " Limit" + limit;

private static string BuildSelect(string where, string orderBy, int limit)
{
string sql = "SELECT {0} FROM {1} ";
if (!string.IsNullOrEmpty(where))
sql += where.Trim().StartsWith("where", StringComparison.CurrentCultureIgnoreCase) ? where : "WHERE " + where;
if (!String.IsNullOrEmpty(orderBy))
sql += orderBy.Trim().StartsWith("order by", StringComparison.CurrentCultureIgnoreCase) ? orderBy : " ORDER BY " + orderBy;
if (limit > 0)
sql += " LIMIT " + limit;

return sql;
}