Skip to content

1.0.10: feat: Report SQL syntax errors on exact line within multi-line queries

Choose a tag to compare

@pierresh pierresh released this 14 Nov 05:11
· 41 commits to master since this release
Previously, SQL syntax errors were always reported at the line where prepare()
or query() was called. For multi-line SQL queries, this made it hard to find
the actual error location.

Now the extension extracts the row number from SQLFTW's token information and
calculates the exact PHP line number where the syntax error occurs.

Changes:
- Updated SqlLinterInterface to return structured errors with sqlLine info
- Modified SqlFtwAdapter to extract row numbers from SQLFTW error tokens
- Updated ValidatePdoSqlSyntaxRule to calculate actual PHP line numbers
- Handle edge cases where error token is at end of query (use last token)

Example:
```php
$stmt = $this->db->prepare("SELECT id, name,
    FROM users        // ← Error now reported on THIS line
    WHERE id = 1");
```

Before: Error reported on line 16 (the prepare() line)
After: Error reported on line 17 (the FROM line where error actually is)

Test coverage:
- Added test cases for multi-line SQL with errors on lines 2 and 3
- Added test for "end of query" errors
- All existing tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>