Tomer Moran
Tomer Moran
DTDrizzle Team
Created by Tomer Moran on 12/4/2023 in #help
DB operations don't execute when promise is not awaited
Update: I've fixed the above ES query to the following:
UnaryExpression[operator="void"] > CallExpression > MemberExpression[property.name!="execute"] CallExpression MemberExpression:matches([object.name="db"], [object.name="tx"])
UnaryExpression[operator="void"] > CallExpression > MemberExpression[property.name!="execute"] CallExpression MemberExpression:matches([object.name="db"], [object.name="tx"])
This matches expressions where void is used on a chain of functions on db or tx, which doesn't end with .execute(). I'm not going to submit a PR for this because there are a lot of edge cases which are not accounted for here, but this version is more precise than the one I posted before.
8 replies
DTDrizzle Team
Created by Tomer Moran on 12/4/2023 in #help
DB operations don't execute when promise is not awaited
Hello again. I am using the no-restricted-syntax rule for simplicity, so I wrote the following AST selector:
UnaryExpression[operator="void"] MemberExpression[object.name="db"]
UnaryExpression[operator="void"] MemberExpression[object.name="db"]
It's not 100% precise since it can potentially have false-positives, and it also assumes Drizzle is used via a variable called db, but good enough for my purposes Leaving this here in case it helps others.
8 replies
DTDrizzle Team
Created by Tomer Moran on 12/4/2023 in #help
DB operations don't execute when promise is not awaited
Ok, thanks. I think this behaviour is potentially problematic. I'll see if I can write a custom eslint rule to catch this
8 replies
DTDrizzle Team
Created by Tomer Moran on 6/11/2023 in #help
How to declare 1-to-0:1 relation between tables?
Hey @Dan Kochetov, circling back on the above. Would you have any ideas? Thanks
5 replies
DTDrizzle Team
Created by Tomer Moran on 6/11/2023 in #help
How to declare 1-to-0:1 relation between tables?
Yes, that's right. Here's an example: 1. users table with id: varchar(255) as primary key. 2. secretSettings table with userId: varchar(255) primary key, referencing the users table; as well as a bunch of data columns storing secret settings. A user may have zero or one entry in secretSettings . I realize that this can be implemented by just creating a nullable column within the users table, but I want to keep them separate due to security concerns
5 replies