Flowframe / laravel-trend

Generate trends for your models. Easily generate charts or reports.
MIT License
606 stars 64 forks source link

Add support for SQL Server #35

Closed kokoshneta closed 1 year ago

kokoshneta commented 1 year ago

First-time collaborator, be gentle. :-)

Since SQL Server is not yet supported, I thought I’d make an attempt at adding support.

Unlike the already supported drivers, SQL Server does not support grouping results by column aliases, which makes things a little trickier and required a few workarounds. The way I got around it was to add a groupColumn() method in the abstract adapter, which returns null, and then override that method in the SQL Server adapter, where instead it returns the date calculation. In the base class, an added groupColumn() method calls the adapter method and then defaults to the dateAlias if the adapter method returns null.

Yashar8991 commented 1 year ago

there is not groupColumn( ) in SQL Server

kokoshneta commented 1 year ago

there is not groupColumn( ) in SQL Server

I don’t understand your point. There isn’t a groupColumn() function in any of the supported databases. There also aren’t format() functions. These aren’t database functions, but PHP class methods in the adapter and the base class. All groupColumn() does is abstract away the reference to the column being grouped by in a way that allows the different drivers to implement their own logic.

Yashar8991 commented 1 year ago

sorry , my bad

kokoshneta commented 1 year ago

Closing this as outdated; replaced by #39.