-
Notifications
You must be signed in to change notification settings - Fork 18
Allows publishing on systems with table prefixes #80
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
base: main
Are you sure you want to change the base?
Conversation
Found a bug. I'm using typeorm in multiple systems sharing the same database, so I need my burdy install to have it's tables prefixed (i.e. `blog_posts`). Turns out that typeorm doesn't support table aliases when updating (and won't support them in the future): typeorm/typeorm#1798. This PR fixes it. I'm getting a "Unknown column 'post.id' in 'where clause" error when attempting to publish/unpublish items. Generated query: UPDATE `blog_post` SET `publishedAt` = '2022-01-10 03:03:15.945', `status` = 'published', `publishedFrom` = '2022-01-10 03:03:15.945', `publishedUntil` = NULL, `updatedAt` = '2022-01-10 03:03:15.945' WHERE post.id IN (1, 2, 3) Steps to reproduce: - Set up a table prefix with the `TYPEORM_ENTITY_PREFIX` - Attempt to publish a post.
Hi @bombozama, Nice find! Is this the only API that's being affected? There are more places where this is being used. Are they affected as well? In that case, it might make sense to abstract the TypeORM query or patch the relevant query builder functions. |
I've been looking (not too hard) for other aliased updates within burdy but haven't been able to find any others. Let me take a deeper look and I'll let you know. |
So I found the problem in just three places:
Asides from the fix in the first commit, the only other places I could find the same problem were when In my opinion, no additional abstraction is needed, just considering the case in the future should suffice. Please note that the problem is only on aliased update statements. Selects work like a charm no need to reconfigure anything else. Hope it helps. |
Hi @bombozama thank you very much! Ill take a look at it tomorrow |
Found a bug. I'm using typeorm in multiple systems sharing the same database, so I need my burdy install to have it's tables prefixed (i.e.
blog_posts
). Turns out that typeorm doesn't support table aliases when updating (and won't support them in the future): typeorm/typeorm#1798. This PR fixes it.I'm getting a
Unknown column 'post.id' in 'where clause
error when attempting to publish/unpublish items.Generated query:
Steps to reproduce:
TYPEORM_ENTITY_PREFIX
.env var