-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added driver to support for Sql Server #60
Conversation
… driver - changed driver connection from sqlserver -> sqlsrv
I just notice that there is another pull request that adds support for SQL server. Still, I think this one is better because this one is using CONVERT SQLserver function to format date column and the other one is using FORMAT function which is slower and locale aware. Also the other pull request unnecessary refactor code in Trend service IMO. |
b5dd8fb
to
7315213
Compare
I don't think this is working? I tried your fork today and this is the SQL that was generated: SELECT
CONVERT(VARCHAR, created_at, 23) AS date,
count(*) AS aggregate
FROM
[ crm ].[ account_notes ]
WHERE
[ created_at ] BETWEEN 2024 -03 -12 01: 59: 02.687
AND 2024 -03 -19 01: 59: 02.687
GROUP BY
[ CONVERT(VARCHAR, created_at, 23) ]
ORDER BY
[ date ] ASC
Manually fixed the query to be working: SELECT
CONVERT(VARCHAR, [created_at], 23) AS date,
count(*) AS aggregate
FROM
[crm].[account_notes]
WHERE
[created_at] BETWEEN '2024-03-12 01:59:02.687'
AND '2024-03-19 01:59:02.687'
GROUP BY
CONVERT(VARCHAR, [created_at], 23)
ORDER BY
[date] ASC I removed spaces from inside the brackets, fixed the date strings, and removed the brackets from around the group by clause. |
I've fixed the problem with groupBy clause when using SQL server driver and tested it against SQL Server 2022. It should work fine now. |
Working now, thanks! SELECT
CONVERT(VARCHAR, created_at, 23) AS date,
count(*) AS aggregate
FROM
[crm].[tickets]
WHERE
[created_at] BETWEEN '2024-03-12 12:29:28.806'
AND '2024-03-19 12:29:28.806'
GROUP BY
CONVERT(VARCHAR, created_at, 23)
ORDER BY
[date] ASC Is there a way for you to wrap the column name in brackets in case it's a reserved word? |
I've push latest commit that encloses date column name in square brackets. |
Tested and working great, thanks! SELECT
LEFT(CONVERT(VARCHAR, [add_date], 23), 7) AS date,
sum(scale_quantity) AS aggregate
FROM
[crm].[tickets]
WHERE
[commodity_id] = 'corn'
AND [add_date] BETWEEN '2023-03-19 20:35:42.983'
AND '2024-03-19 20:35:42.983'
GROUP BY
LEFT(CONVERT(VARCHAR, [add_date], 23), 7)
ORDER BY
[date] ASC @Larsklopstra can we have this reviewed and merged whenever you have a chance? |
I got looking at this again today and I started wondering if this could potentially be vulnerable to SQL injection if the developer for some reason accepted input for the |
Sorry, I won't be support Sql Server OOTB. The new extensible version will allow you to add your own drivers |
I've created driver for the SQL server and updated readme file to document driver support.