使用 over() 和别名时的 mysql 错误
使用 phpMyAdmin 控制台和 MariaDB 10.2,如果我将 over() 函数与别名结合使用,则会出现各种错误:
Using the phpMyAdmin console and MariaDB 10.2, if I combine the over() function with an alias I get a variety of errors:
SELECT AVG(foo) OVER() AS bar FROM some_table
- 之前发现了一个别名(靠近 bar)
- 意外标记(靠近条形)
- 需要一个别名(靠近 )<-- 只是一个空格
这些带有任一功能的语句都不会给我错误
these statements with either one function don't give me errors
SELECT AVG(foo) AS bar FROM some_table
SELECT AVG(foo) OVER() FROM some_table
我能找到的所有内容都暗示这些错误来自基本错误,例如逗号不合适,或使用保留关键字作为别名.我不认为我在做任何事情.
All of the stuff I can find implies that these errors come from basic mistakes, like having a comma out of place, or using reserved keywords as aliases. I don't think I'm doing any of that.
推荐答案
似乎 phpMyAdmin 用于验证语法的 linter 似乎尚未针对 MariaDB 10.2 引入的这种语法进行更新.虽然这很烦人,但您可以忽略警告并运行您的查询.
It appears the linter that phpMyAdmin uses for verifying syntax hasn't been updated for this syntax that seems to have been introduced with MariaDB 10.2. While it's annoying, you can ignore the warnings and run your query anyway.
我在 https://github.com 打开了一个关于它的错误报告/phpmyadmin/sql-parser/issues/197,您可以在此处继续操作,直到错误修复为止.
I've opened a bug report about it at https://github.com/phpmyadmin/sql-parser/issues/197, where you can follow along until the bug is fixed.
相关文章