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
Caanot build arbitrary Queries without "from" for root Select #378
Comments
I don't think this is a bug? The root starting query builder needs a table, no? |
Not necessarily a bug but definitely an issue examples Select NOW(); select 1 where (Select count(*)>0 from some_table ); These are very basic examples but are valid nonetheless. also by forcing the from when using multiple add_select for unrelated data points in a single row it moves some of the encapsulation that the subselects provide as an alias. ie its a little harder to read/understand IMHO |
Writing the query out like this makes more sense: SELECT
(SELECT MAX(updated_at) AS updated_at FROM different_table) AS other_test,
(SELECT MAX(updated_at) AS updated_at FROM another_table) AS some_alias; |
Not all databases support this .. 🤔 |
@circulon Fixed this but i didn't add support to limits, wheres or group bys or anything .. I couldn't find any query examples where you would select without a table and have a limit, where or group bys. I can add this back if this is valid syntax but everything I read says selecting without a table isn't even really valid SQL lol. Maybe you can help me |
Yeah that was probably a poor example to explain the point. Apologies for not being more concise I'm using Query builder very muck like the original example to add multiple subqueries with aliases. I hope this clarifies things? Happy to discuss things further if you like? |
Describe the bug
When using the query builder there must be a "table" or "from_" in the root of the query even if it is not used
To Reproduce
Should build a query along the lines of
Instead Throws an exception ending with
Note: Adding the following to the beginning of the chain compiles the query as expecetd
Expected behavior
A valid query should be compiled
Desktop (please complete the following information):
What database are you using?
Additional context
masonite orm 1.0.22
The text was updated successfully, but these errors were encountered: