barryvdh / laravel-ide-helper

IDE Helper for Laravel
MIT License
14.25k stars 1.17k forks source link

Incorrect syntax near '(' sqlsrv #1588

Open ciaksoy opened 2 months ago

ciaksoy commented 2 months ago

Versions:

Description:

When I use php artisan ide-helper:models, the following query gives Incorrect syntax near ‘(’ error

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '('.
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 'TABLE_NAME'
  and ls.name = schema_name()
group by 
  fk.name, 
  fs.name, 
  ft.name, 
  fk.update_referential_action_desc, 
  fk.delete_referential_action_desc
menglisch commented 1 month ago

When running the command you get the error or does the command changes the query and the error occurs after running the query?