mmurto
mmurto
Explore posts from servers
DTDrizzle Team
Created by mmurto on 4/17/2023 in #help
Raw SQL / Postgres stored generated column in schema
Is it possibile to add raw sql, or more specifically stored generated columns to the schema? Trying to store a length field of a text column.
1 replies
DTDrizzle Team
Created by mmurto on 4/12/2023 in #help
How to count joined table?
I'm trying to count rows returned by join for a query, basically the same as this: https://dba.stackexchange.com/questions/110850/count-rows-with-inner-joined-tables How to convert this to Drizzle? Any documentation I've missed regarding this kind of things?
SELECT t1.team_name,
IFNULL(t2.num_players, 0) AS strength,
t1.team_timestamp
FROM team t1
LEFT OUTER JOIN
(SELECT team_id, COUNT(team_id) AS num_players
FROM player
GROUP BY team_id
) t2
ON t1.team_id = t2.team_id
-- GROUP BY t1.team_id, t1.team_name, t1.season_id -- **NOTE** - see discussion below
ORDER BY strength DESC, team_name ASC;
SELECT t1.team_name,
IFNULL(t2.num_players, 0) AS strength,
t1.team_timestamp
FROM team t1
LEFT OUTER JOIN
(SELECT team_id, COUNT(team_id) AS num_players
FROM player
GROUP BY team_id
) t2
ON t1.team_id = t2.team_id
-- GROUP BY t1.team_id, t1.team_name, t1.season_id -- **NOTE** - see discussion below
ORDER BY strength DESC, team_name ASC;
2 replies
DTDrizzle Team
Created by mmurto on 4/9/2023 in #help
How to filter length in where for postgres?
I have a text field, which I want to select only if it's length is higher than 50. How should I do that? So I basically need to transfer where length(item.content) >= 50 to Drizzle.
4 replies
DTDrizzle Team
Created by mmurto on 3/17/2023 in #help
Argument of type 'SQL<unknown>' is not assignable to parameter
I have the following:
const projects = await db
.select()
.from(project)
.where(eq(project.ownerId, userId));
const projects = await db
.select()
.from(project)
.where(eq(project.ownerId, userId));
and the eq() gives an error like:
Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: { id: MySqlColumn<{ data: string; driverParam: string | number; notNull: true; hasDefault: true; tableName: "Project"; }>; name: MySqlColumn<{ data: string; driverParam: string | number; hasDefault: false; notNull: true; tableName: "Project"; }>; description: MySqlColumn<...>; createdAt: My...'.

Type 'Name' is not assignable to type 'Chunk'.
Property 'encoder' is missing in type 'Name' but required in type 'Param<unknown, unknown>'.ts(2345)
index.d.ts(80, 14): 'encoder' is declared here.
Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: { id: MySqlColumn<{ data: string; driverParam: string | number; notNull: true; hasDefault: true; tableName: "Project"; }>; name: MySqlColumn<{ data: string; driverParam: string | number; hasDefault: false; notNull: true; tableName: "Project"; }>; description: MySqlColumn<...>; createdAt: My...'.

Type 'Name' is not assignable to type 'Chunk'.
Property 'encoder' is missing in type 'Name' but required in type 'Param<unknown, unknown>'.ts(2345)
index.d.ts(80, 14): 'encoder' is declared here.
What could be the problem?
10 replies