phpmyadmin / sql-parser

A validating SQL lexer and parser with a focus on MySQL dialect.
https://packagist.org/packages/phpmyadmin/sql-parser
GNU General Public License v2.0
443 stars 103 forks source link

Syntax error with row_number alias #387

Open DorianCoding opened 1 year ago

DorianCoding commented 1 year ago

When using ROW_NUMBER and an alias such as :

SELECT ROW_NUMBER() OVER (ORDER BY `start`)

Phpmyadmin is showing an error but the query works.

It says "An alias was previously found" near the index.

image

Server configuration

Client configuration

williamdes commented 1 year ago

Bonjour ! Thank you for reporting this issue, I moved it here so we can investigate about it. @iifawzi I am not sure if any of your recent PRs fix this one ?

iifawzi commented 1 year ago

I bet that we've seen this bug before, I will take a deeper look

iifawzi commented 1 year ago

The issue is already fixed by https://github.com/phpmyadmin/sql-parser/pull/360#issuecomment-954721943. Kindly @DorianCoding, can you test with the latest version? (5.2.0)

williamdes commented 1 year ago

_(phpMyAdmin 5.2+snapshot) also available as a non official docker image_

DorianCoding commented 1 year ago

The issue is already fixed by #360 (comment). Kindly @DorianCoding, can you test with the latest version? (5.2.0)

It seems indeed that the problem is solved using phpmyadmin 5.2 with XAMPP on Windows (with same browser). I guess I just have to wait the update of ubuntu packages then.

williamdes commented 1 year ago

The issue is already fixed by #360 (comment). Kindly @DorianCoding, can you test with the latest version? (5.2.0)

It seems indeed that the problem is solved using phpmyadmin 5.2 with XAMPP on Windows (with same browser). I guess I just have to wait the update of ubuntu packages then.

I am the one responsible for the packaging on Ubuntu and Debian, I am quite behind schedule and sorry about that. I will keep you updated

williamdes commented 1 year ago

I am the one responsible for the packaging on Ubuntu and Debian, I am quite behind schedule and sorry about that. I will keep you updated

It's been a while, the PPA is updated for Jammy. Can you please check our Wiki for install methods on Ubuntu/Debian

tcharbonnier-gp-aviva commented 6 months ago

Error is still there in phpMyAdmin 5.2.1 image Query : SELECT *, ROW_NUMBER() OVER(PARTITION BY SUBSTR(`created_at`, 1, 10), SUBSTR(`date`, 1, 10), `customer_id` ORDER BY `id` DESC) AS _row_number_ FROM `wp_8_ava_appointments` WHERE `deleted_at` IS NULL

williamdes commented 6 months ago

Thank you for confirming this

niconoe- commented 1 month ago

I can't reproduce the error using the parser on 5.10.x.

This might be fixed by the fact ROW_NUMBER is now included in the dictionnaries of functions, which wasn't the case before #572.

@williamdes I let you give it a try to double-check and confirm this is fixed now.