You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which assigns a new field slice to tq.ctx.Fields, clearing previous fields by Select(). Because of this, the SQL:
SELECTDATE(created_at) ASdate,
service_name, COUNT(*) AS total,
SUM(state =3)/COUNT(*) AS success_rate,
(COUNT(*) -COUNT(DISTINCT commit)) AS repeated_builds,
AVG(TIMESTAMPDIFF(SECOND, created_at, finished_at)) AS avg_build_time
FROM tasks
WHERE created_at IS NOT NULLAND finished_at IS NOT NULLAND created_at >= ? AND created_at <= ?
GROUP BYdate, service_name
which I have to wrap everything inside Modify instead of use Select() and GroupBy() after Query(). Otherwise, the query will only select date and task.FieldServiceName, and since there's no reference for date, the query will fail with unknown date column. Did I miss something or it's the only way?
2. What functions can accept expression (e.g., column with SQL functions)? According to the official documentation, only selector in Modify includes SQL functions, the Select() after Query() only uses field names. So, only Modify() can contain expressions? In the Modify() section, it mentioned:
"lets add custom SQL modifiers to the builders" - I can also do that after the Query(), what the purpose of it?
"mutate the statements before they are executed." - How and which part of SQL does it mutate?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I want to know some key designs of the the query builder:
GroupBy()
override the columns selected bySelect()
? According to the generated code for my task entity:Which assigns a new field slice to
tq.ctx.Fields
, clearing previous fields bySelect()
. Because of this, the SQL:has to be written like:
which I have to wrap everything inside Modify instead of use
Select()
andGroupBy()
after Query(). Otherwise, the query will only selectdate
andtask.FieldServiceName
, and since there's no reference for date, the query will fail with unknown date column. Did I miss something or it's the only way?2. What functions can accept expression (e.g., column with SQL functions)? According to the official documentation, only selector in Modify includes SQL functions, the
Select()
afterQuery()
only uses field names. So, onlyModify()
can contain expressions? In theModify()
section, it mentioned:Query()
, what the purpose of it?Beta Was this translation helpful? Give feedback.
All reactions