RiftLurker
RiftLurker
DTDrizzle Team
Created by RiftLurker on 7/17/2024 in #help
SELECT 'value'
Is there some way to model SELECT 'value' without a table in drizzle? Specifically I'm trying to do something like
SELECT
value
FROM
user_config
WHERE
user_id = 1
UNION ALL
SELECT
'fallback'
SELECT
value
FROM
user_config
WHERE
user_id = 1
UNION ALL
SELECT
'fallback'
but couldn't find a way to create the SELECT for unionAll
const query = db.select({
value: UserConfig.value,
})
.from(UserConfig)
.where(eq(UserConfig.userId, 1))

query.unionAll(
// How to create select here?
)
const query = db.select({
value: UserConfig.value,
})
.from(UserConfig)
.where(eq(UserConfig.userId, 1))

query.unionAll(
// How to create select here?
)
I can of course create it as a raw query and handle the types myself
sql`${query} UNION ALL SELECT ${'fallback'}`
sql`${query} UNION ALL SELECT ${'fallback'}`
8 replies