Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing left join in UPDATE statement build #260

Closed
wheng82 opened this issue Sep 24, 2019 · 4 comments
Closed

Missing left join in UPDATE statement build #260

wheng82 opened this issue Sep 24, 2019 · 4 comments
Assignees
Labels
Milestone

Comments

@wheng82
Copy link

wheng82 commented Sep 24, 2019

Dear sqlparser developer: Hello

Thank you very much and your team for developing PHP myadmin / sql-parser, an excellent PHP parser component with SQL grammar, which has helped me solve a series of crud-related interface problems. At present, I have used the software provided by you to implement a select SQL statement to complete a table, turn pages, query, repair. Change, add, delete operations.

I found a requirement in the process of using, that is, tables for join can also implement the update function, I hope you can add the corresponding function here.

For example, I have a select statement

Select u.*, ud. nickname from user u left join user_detail ud on u. id = ud. user_id where u.del = 0

I hope that I can update the data of the join table when I update it, but the syntax of the join part will be lost when this sentence is translated into the update statement at present.

for example

Update user u left join user_detail UD on u.id = ud.user_id set ud.ip ='33' where u.id = 1

This statement becomes $parser - > statements [0] - > build () code after new parser ($sql)

UPDATE user `u`SET ud.ip ='33' WHERE u.id = 1

The join part is missing, and there is no join module under the document update state in the hope of being resolved.

Thanks very much! Best wishes for sql-parser!

@wheng82
Copy link
Author

wheng82 commented Sep 24, 2019

Dear sqlparser developer: Hello
Thank you and your team for developing phpmyadmin/sql-parser, an excellent sql syntax analysis component for php, which helped me solve a series of CRUD-related interface problems. At present, I have used the software you provided to implement a select Sql statement, realize the complete, page turning, query, modify, add, delete operation of a table.
I found a requirement in the process of using it, that is, the update function can also be implemented for the join table, and I hope you can add the corresponding function here.
For example, I have a select statement
select u.*,ud.nickname from user u left join user_detail ud on u.id = ud.user_id where u.del = 0
I hope that the data in the linked table can be updated normally when I update, but the syntax of the join part will be lost when this statement is translated into an update statement
For example

update user u left join user_detail ud on u.id = ud.user_id set ud.ip ='33' where u.id = 1

After this statement passes through new parser($sql), the $parser->statements[0]->build() code becomes

UPDATE user u SET ud.ip = '33' WHERE u.id = 1

The join part is lost, and there is no join module under the update statement according to the document. Hope it can be resolved
Thank you so much! I wish sql-parser better and better!

@wheng82 wheng82 closed this as completed Jun 23, 2020
@williamdes williamdes reopened this Jun 23, 2020
@williamdes
Copy link
Member

Hi @wheng82
I am sorry we did forget to reply to you

@williamdes

This comment was marked as outdated.

@williamdes

This comment was marked as outdated.

@williamdes williamdes added bug and removed question labels Apr 21, 2023
@williamdes williamdes changed the title Relevant problems about missing join module in update statement of sqlparser are expected to be repaired Missing left join in UPDATE statement build Apr 21, 2023
williamdes added a commit that referenced this issue Apr 21, 2023
Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes williamdes added this to the 5.8.0 milestone Apr 21, 2023
@williamdes williamdes self-assigned this Apr 21, 2023
williamdes added a commit that referenced this issue May 8, 2023
…NER JOIN` on `UpdateStatement`

Pull-request: #443
Fixes: #260

Signed-off-by: William Desportes <williamdes@wdes.fr>
williamdes added a commit that referenced this issue May 8, 2023
Pull-request: #443

Signed-off-by: William Desportes <williamdes@wdes.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants