Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Drizzle support #21

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading