If you are on 1.9/develop, you can try to replace L#123 in /core/classes/database/query/builder/join.php by this:
if ($this->_table instanceof \Database_Query_Builder_Select) { // Compile the subquery and add it $sql .= ' ('.$this->_table->compile().')'; } else { // Quote the table name that is being joined $sql .= ' '.$db->quote_table($this->_table); }
and then your first example should work.
Let me know if it does, so I can commit it. I don't have time to test it myself atm.
hi, i use \DB::expr() in join for that query: $a = \DB::select() ->from([\Acl\Model_User::table(), 'u']) ->join([\DB::expr('(SELECT id FROM acl_users_groups)'), 'g'], 'left') ->on('g.id', '=', 'u.group_id') ->execute(); query : SELECT * FROM "acl_users" AS "u" LEFT JOIN (SELECT id FROM acl_users_groups) AS "g" ON ("g"."id" = "u"."group_id")
Ah, but you added the brackets, and the TS didn't, so that is why it didn't work for you.
Good to know this is being used, because I've implemented DB::expr() explicitly, which would break your code because it would add brackets again. I'll take that into account.
hi Harro , i add new line to join.php (https://github.com/fuel/core/commit/f1db7c9a8b27cd2afd6ceb223909610bfebf8902 ) and work with subquery in join but not work with DB::expr() in this query : ->join([\DB::expr('SELECT * FROM acl_users_groups'), 'g'], 'left') not add table alias (g) to query, Doyouhave any suggestions?