Skip to content

Commit

Permalink
Add Drizzle support
Browse files Browse the repository at this point in the history
  • Loading branch information
qianl15 committed Aug 28, 2024
1 parent 2cea4b8 commit 835598e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion dbos-rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ function makeSqlInjectionCode(code: string, sqlClient: string): string {
query(query: string, ...values: any[]) {}
}
class PgDatabase {
execute(query: string, ...values: any[]) {}
}
function Transaction(target?: any, key?: any, descriptor?: any): any {
return descriptor;
}
Expand Down Expand Up @@ -244,7 +248,13 @@ const testSet: TestSet = [
// Success test #9 (testing unsubstituted template literals)
makeSqlInjectionSuccessTest(`
ctxt.client.raw(\`foo\`);
`)
`),

// Success test #10 (testing Drizzle support)
makeSqlInjectionSuccessTest(`
ctxt.client.execute("foo");`,
"PgDatabase"
)
],

[
Expand Down
2 changes: 1 addition & 1 deletion dbos-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ormClientInfoForRawSqlQueries: Map<string, string[]> = new Map([
["PrismaClient", ["$queryRawUnsafe", "$executeRawUnsafe"]], // For Prisma
["EntityManager", ["query"]], // For TypeORM
["PoolClient", ["query"]], // This is supported in `dbos-transact` (see `user_database.ts`, but not sure what ORM this corresponds to)
// ["PgDatabase", []], // For Drizzle (TODO: add full support for this)
["PgDatabase", []], // For Drizzle (Currently we don't detect raw SQL calls for Drizzle)
]);

const assignmentTokenKinds = new Set([
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dbos-inc/eslint-plugin",
"version": "3.3.3",
"version": "3.3.4",
"description": "eslint plugin for DBOS SDK",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit 835598e

Please sign in to comment.