Issue Type: Bug Bug
Affects Versions: 3.6.10, 3.6.9, 3.6.8, 3.6.7, 3.6.6, 3.6.5, 3.6.4, 3.6.3
Assignee: Unassigned
Components: core
Created: 18/Dec/12 7:53 AM
Description:

The combination of the below code:

protected static void replaceDistinctWithGroupBy(StringBuilder sql) {
		int distinctIndex = sql.indexOf(DISTINCT);
		if (distinctIndex > 0) {
			sql.delete(distinctIndex, distinctIndex + DISTINCT.length() + 1);
			sql.append(" group by").append(getSelectFieldsWithoutAliases(sql));
		}
	}

and

protected static CharSequence getSelectFieldsWithoutAliases(StringBuilder sql) {
		String select = sql.substring(sql.indexOf(SELECT) + SELECT.length(), sql.indexOf(FROM));

		// Strip the as clauses
		return stripAliases(select);
	}

may corrupt queries where a column contains the keyword 'from'. For example:

select distinct g.id, g.validFrom from SOME_TABLE g

A possible quick fix would be to not match against the word "from" but rather " from" or similar.

Project: Hibernate ORM
Labels: core dialect sqlserver
Priority: Critical Critical
Reporter: Alix Warnke
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira