Allows publishing on systems with table prefixes#80
Allows publishing on systems with table prefixes#80bombozama wants to merge 5 commits intoburdy-io:mainfrom
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 clauseerror when attempting to publish/unpublish items.Generated query:
Steps to reproduce:
TYPEORM_ENTITY_PREFIX.env var