Guilherme Rosado
Guilherme Rosado
Explore posts from servers
DTDrizzle Team
Created by Guilherme Rosado on 9/15/2023 in #help
[HELP]: I'm trying to re-create a CTE-insert in drizzle, having some difficulties
with cart_products as (
select * from cart_product where cart_id = ${cartId}
)
insert into order_product (order_id, cart_product_id)
select ${orderId}, id from cart_products
returning
id,
order_id as "orderId",
cart_product_id as "cartProductId";
with cart_products as (
select * from cart_product where cart_id = ${cartId}
)
insert into order_product (order_id, cart_product_id)
select ${orderId}, id from cart_products
returning
id,
order_id as "orderId",
cart_product_id as "cartProductId";
How does the query above translate to drizzle? I think more examples that translates to the above would be awesome in the docs, I've been fighting a bit with the API. I know from the start how to do it on sql, but sometimes it gets really hard translating to drizzle. I feel this could be solved with more examples, maybe?
114 replies
DTDrizzle Team
Created by Guilherme Rosado on 8/28/2023 in #help
Bug on custom type inference? Maybe I'm doing something wrong.
export const timez = customType<
{
data: Date;
driverData: string;
config: { precision?: number };
}
>({
dataType(config) {
const precision = typeof config?.precision !== 'undefined'
? ` (${config.precision})`
: '';
return `time${precision} with time zone`;
},
fromDriver(value: string): Date {
return new Date(value);
},
});
export const timez = customType<
{
data: Date;
driverData: string;
config: { precision?: number };
}
>({
dataType(config) {
const precision = typeof config?.precision !== 'undefined'
? ` (${config.precision})`
: '';
return `time${precision} with time zone`;
},
fromDriver(value: string): Date {
return new Date(value);
},
});
Then if I:
endTime: timez("end_time"),

// I get from inference

type Type = {
endTime?: any;
}
endTime: timez("end_time"),

// I get from inference

type Type = {
endTime?: any;
}
The type on endTime should be Date not any I'm using drizzle-orm 0.28.5
14 replies
SSolidJS
Created by Guilherme Rosado on 3/31/2023 in #support
How do I test this behavior?
I want to test the following behavior but I think there's no DOM tree here, right? When we're testing SolidJS components how do I visualize the current tree?
describe("Turnstile Component", () => {
it("renders the Turnstile component", () => {
createRoot(() => {
const container = (
<Turnstile sitekey="" onToken={(t) => {}} />
) as HTMLDivElement;

expect(container.outerHTML).toBe("<div></div>");
console.log("SCRIPT: ", document.querySelector("#turnstile-script")); // null, onMount creates an element with the id="turnstile-script"
});
});
});
describe("Turnstile Component", () => {
it("renders the Turnstile component", () => {
createRoot(() => {
const container = (
<Turnstile sitekey="" onToken={(t) => {}} />
) as HTMLDivElement;

expect(container.outerHTML).toBe("<div></div>");
console.log("SCRIPT: ", document.querySelector("#turnstile-script")); // null, onMount creates an element with the id="turnstile-script"
});
});
});
42 replies