Skip to content

Commit 20b6699

Browse files
committed
chore(driver): validate when statement is a string
1 parent 0a61809 commit 20b6699

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/database",
3-
"version": "5.28.0",
3+
"version": "5.29.0",
44
"description": "The Athenna database handler for SQL/NoSQL.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/database/drivers/MySqlDriver.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,16 @@ export class MySqlDriver extends Driver<Knex, Knex.QueryBuilder> {
929929
}
930930

931931
if (operation === undefined) {
932+
if (Is.Array(statement)) {
933+
throw new Error('Arrays as statement are not supported.')
934+
}
935+
936+
if (Is.String(statement)) {
937+
throw new Error(
938+
`The value for the "${statement}" column is undefined and where will not work.`
939+
)
940+
}
941+
932942
this.qb.where(statement)
933943

934944
return this

src/database/drivers/PostgresDriver.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,16 @@ export class PostgresDriver extends Driver<Knex, Knex.QueryBuilder> {
923923
}
924924

925925
if (operation === undefined) {
926+
if (Is.Array(statement)) {
927+
throw new Error('Arrays as statement are not supported.')
928+
}
929+
930+
if (Is.String(statement)) {
931+
throw new Error(
932+
`The value for the "${statement}" column is undefined and where will not work.`
933+
)
934+
}
935+
926936
this.qb.where(statement)
927937

928938
return this

src/database/drivers/SqliteDriver.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,16 @@ export class SqliteDriver extends Driver<Knex, Knex.QueryBuilder> {
922922
}
923923

924924
if (operation === undefined) {
925+
if (Is.Array(statement)) {
926+
throw new Error('Arrays as statement are not supported.')
927+
}
928+
929+
if (Is.String(statement)) {
930+
throw new Error(
931+
`The value for the "${statement}" column is undefined and where will not work.`
932+
)
933+
}
934+
925935
this.qb.where(statement)
926936

927937
return this

0 commit comments

Comments
 (0)