CTE (Common Table Expression) with aliases support #1415

Open
opened 2019-09-06 07:27:37 +00:00 by typeless · 0 comments
typeless commented 2019-09-06 07:27:37 +00:00 (Migrated from github.com)

After xorm/builder#59 we can do
Join(Select(...), ...)
It would be more useful if it can support aliases like the following SQLs (SQLite dialect):

WITH r AS (
  SELECT * 
  FROM 
  repository
), u AS (
  SELECT * 
  FROM 
  user
) SELECT 
  u.name, 
  r.name 
FROM 
  u 
JOIN 
  r ON u.id = r.owner_id;
SELECT 
  user.id, 
  r.name 
FROM 
  user 
JOIN (
  SELECT * 
  FROM 
  repository) AS r ON user.id = r.owner_id;

Note that builder.From supports aliases already. This issue is mainly about builder.Join.

After https://gitea.com/xorm/builder/pulls/59 we can do `Join(Select(...), ...)` It would be more useful if it can support aliases like the following SQLs (SQLite dialect): ``` WITH r AS ( SELECT * FROM repository ), u AS ( SELECT * FROM user ) SELECT u.name, r.name FROM u JOIN r ON u.id = r.owner_id; ``` ``` SELECT user.id, r.name FROM user JOIN ( SELECT * FROM repository) AS r ON user.id = r.owner_id; ``` Note that `builder.From` supports aliases already. This issue is mainly about `builder.Join`.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1415
No description provided.