Skip to content

Fix rawAddPrefix() to add prefix to all tables in raw query#1034

Open
alikm6 wants to merge 2 commits intoThingEngineer:masterfrom
alikm6:bugfix02
Open

Fix rawAddPrefix() to add prefix to all tables in raw query#1034
alikm6 wants to merge 2 commits intoThingEngineer:masterfrom
alikm6:bugfix02

Conversation

@alikm6
Copy link

@alikm6 alikm6 commented Jun 28, 2024

In the rawAddPrefix function, the prefix is added only to the first table in the query, if we have join and ... in the query, the prefix must be added to the names of all tables.

For example, query

select t1.id as post_id, t2.id as bot_id from posts as t1 inner join bots as t2 on t1.bot_id = t2.id

is converted to

select t1.id as post_id, t2.id as bot_id from tbl_posts as t1 inner join bots as t2 on t1.bot_id = t2.id

when it should be converted to

select t1.id as post_id, t2.id as bot_id from tbl_posts as t1 inner join tbl_bots as t2 on t1.bot_id = t2.id

This issue is resolved in this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant