DataTables / Editor-NET

.NET Framework and .NET Core server-side libraries for Editor
Other
15 stars 12 forks source link

Tory.berra/fix/invalid group clause #21

Open VictorioBerra opened 4 months ago

VictorioBerra commented 4 months ago

Fixes https://github.com/DataTables/Editor-NET/issues/18

Editor .NET needs to include both value and label in the group clause. With SqlServer, you will get "Column '[sites].[x]' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause." if you provide two different columns (IE site.id and site.name).

I tested this on SQL Server, MySQL, Postgres, SQLite. Not Oracle but their docs show the same GROUP BY syntax as others...

Should not break backwards compatibility. I also tested using the same column in the GROUP BY clause twice, IE:

SELECT site.name AS value, site.name AS label
FROM sites
GROUP BY site.name, site.name

Works great across all RDBMSes.