Issue with MS SQL for compileForeignKeys #51947
Unanswered
Devin345458
asked this question in
Q&A
Replies: 1 comment
-
We already have integration tests for You get the same error on |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
11.9
PHP Version
8.3.8
Database Driver & Version
Microsoft SQL Server 2022 - 16.0.4125.3 (X64) on Windows Server 2022 Datacenter 10.0 (Build 20348: ) (Hypervisor)
Description
When trying to run the
compileForeignKeys
in theSqlServerGrammar.php
file. I get the error[S0001][102] Line 2: Incorrect syntax near '('.
I have traced the error back to thestring_agg(lc.name, ',') within group (order by fkc.constraint_column_id) as columns
it appears to be an issue with the within group issue. Removing the within group statement fixes the issue. I'm unsure why it was addedSteps To Reproduce
Schema::getForeignKeys('table');
SQLSTATE[42000]: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Incorrect syntax near '('. (Connection: sqlsrv, SQL: select fk.name as name, string_agg(lc.name, ',') within group (order by fkc.constraint_column_id) as columns, fs.name as foreign_schema, ft.name as foreign_table, string_agg(fc.name, ',') within group (order by fkc.constraint_column_id) as foreign_columns, fk.update_referential_action_desc as on_update, fk.delete_referential_action_desc as on_delete from sys.foreign_keys as fk join sys.foreign_key_columns as fkc on fkc.constraint_object_id = fk.object_id join sys.tables as lt on lt.object_id = fk.parent_object_id join sys.schemas as ls on lt.schema_id = ls.schema_id join sys.columns as lc on fkc.parent_object_id = lc.object_id and fkc.parent_column_id = lc.column_id join sys.tables as ft on ft.object_id = fk.referenced_object_id join sys.schemas as fs on ft.schema_id = fs.schema_id join sys.columns as fc on fkc.referenced_object_id = fc.object_id and fkc.referenced_column_id = fc.column_id where lt.name = N'Corp' and ls.name = schema_name() group by fk.name, fs.name, ft.name, fk.update_referential_action_desc, fk.delete_referential_action_desc).
Beta Was this translation helpful? Give feedback.
All reactions