sql-parser icon indicating copy to clipboard operation
sql-parser copied to clipboard

[Query] Attempt to read property "keyword" on null

Open faissaloux opened this issue 11 months ago • 3 comments

This error appears when I want to access a table that has a column with a backtick on its name ( `col_one in my case ).

[!NOTE] The table must contain at least two records.

Internal error in .\vendor\phpmyadmin\sql-parser\src\Utils\Query.php#413
ErrorException: Attempt to read property "keyword" on null

Backtrace

https://github.com/phpmyadmin/sql-parser/blob/00c8e55cacae20d24fdf74fa0cb54d4aabfe3df9/src/Utils/Query.php#L413

Reproduce

  1. Run
CREATE TABLE `table` (
  `id` int NOT NULL PRIMARY KEY AUTO_INCREMENT,
  ```col_one` int NOT NULL
);

INSERT INTO `table` (```col_one`) VALUES(1), (2);
  1. Try to access the table.

faissaloux avatar Jan 28 '25 14:01 faissaloux

Cross-duplicate of https://github.com/phpmyadmin/phpmyadmin/issues/19349

kamil-tekiela avatar Jan 28 '25 18:01 kamil-tekiela

If my PR gets merged it should fix the issue in PMA. I don't know how we can prevent this problem from occurring in sql-server though.

kamil-tekiela avatar Jan 28 '25 18:01 kamil-tekiela

I don't know how we can prevent this problem from occurring in sql-server though.

sql-parser

I think it will be worth investigating

williamdes avatar Feb 03 '25 14:02 williamdes