Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
webda2l committed Oct 15, 2024
1 parent b90edff commit 96aa155
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
20 changes: 4 additions & 16 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"noUnusedImports": "error",
"noUnusedPrivateClassMembers": "error",
"noUnusedVariables": "error",
"useHookAtTopLevel": "error"
"useHookAtTopLevel": "error",
"noConstantCondition": "warn"
},
"nursery": {
"noDuplicateCustomProperties": "error",
Expand All @@ -36,20 +37,6 @@
"useFilenamingConvention": "error",
"useForOf": "error",
"useFragmentSyntax": "error",
"useNamingConvention": {
"level": "warn",
"options": {
"strictCase": false,
"conventions": [
{
"selector": {
"kind": "objectLiteralMember"
},
"formats": ["camelCase", "snake_case"]
}
]
}
},
"useShorthandArrayType": "error",
"useShorthandAssign": "error",
"useSingleCaseStatement": "error"
Expand All @@ -58,7 +45,8 @@
"noDuplicateAtImportRules": "error",
"noEmptyBlock": "error",
"useErrorMessage": "error",
"useAwait": "error"
"useAwait": "error",
"noExplicitAny": "warn"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type SchemQlOptions = {
type QueryFns = Record<'first' | 'firstOrThrow' | 'all', QueryFn<unknown, Record<string, any>>>
type QueryFn<TQueryResult, TParams> = (sql: string, params?: TParams) => TQueryResult | Promise<TQueryResult>

type QueryExecutor<TMethod extends keyof QueryFns, DB> = <
type QueryExecutor<_TMethod extends keyof QueryFns, DB> = <
TQueryResult = unknown,
TParams extends Record<string, any> = Record<string, any>,
TParamsSchema extends z.ZodTypeAny | undefined = undefined,
Expand Down
20 changes: 10 additions & 10 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const normalizeString = (str: string) => {
const schemQlConfigured = new SchemQl<DB>({
queryFns: {
all: (sql, params) => {
assert.strictEqual(sql, `SELECT * FROM users WHERE id = :id`)
assert.strictEqual(sql, 'SELECT * FROM users WHERE id = :id')
assert.deepEqual(params, {
id: 'uuid-1',
})
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('SchemQl - global options', () => {
it('should return the expected result, using override queriesFn if provided', async () => {
const results = await schemQlConfigured.all({
queryFn: (sql, params) => {
assert.strictEqual(sql, `SELECT * FROM users WHERE id = :id`)
assert.strictEqual(sql, 'SELECT * FROM users WHERE id = :id')
assert.deepEqual(params, {
id: 'uuid-1',
})
Expand Down Expand Up @@ -90,7 +90,7 @@ const schemQlUnconfigured = new SchemQl<DB>({
})

describe('SchemQl - queryFn related', () => {
it('should throw an error if queryFn is missing', async () => {
it('should throw an error if queryFn is missing', () => {
assert.rejects(
async () => {
await schemQlUnconfigured.all({})('SELECT * FROM users')
Expand All @@ -104,9 +104,9 @@ describe('SchemQl - queryFn related', () => {

it('should return the expected result with queryFn as a Promise', async () => {
const results = await schemQlUnconfigured.all({
queryFn: async (sql, params) => {
assert.strictEqual(sql, `SELECT * FROM users`)
return Promise.resolve([
queryFn: async (sql, _params) => {
assert.strictEqual(sql, 'SELECT * FROM users')
return await Promise.resolve([
{
id: 'uuid-1',
email: '[email protected]',
Expand All @@ -133,8 +133,8 @@ describe('SchemQl - queryFn related', () => {
describe('SchemQl - resultSchema related', () => {
it('should return the expected result, parsed by resultSchema if provided', async () => {
const results = await schemQlUnconfigured.all({
queryFn: (sql, params) => {
assert.strictEqual(sql, `SELECT * FROM users`)
queryFn: (sql, _params) => {
assert.strictEqual(sql, 'SELECT * FROM users')
return [
{
id: 'uuid-1',
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('SchemQl - paramsSchema related', () => {
it('should return the expected result, params parsed by paramsSchema if provided', async () => {
const result = await schemQlUnconfigured.first({
queryFn: (sql, params) => {
assert.strictEqual(sql, `SELECT * FROM users WHERE id = :id`)
assert.strictEqual(sql, 'SELECT * FROM users WHERE id = :id')
assert.deepEqual(params, { id: '1' })
return {
id: 'uuid-1',
Expand Down Expand Up @@ -347,7 +347,7 @@ describe('SchemQl - sql literal advanced', () => {
true,
s.sql`
WHERE
${'@users.id-'} ${s.sqlRaw('next' === 'next' ? '>' : '<')} ${':cursor'}
${'@users.id-'} ${s.sqlRaw(true ? '>' : '<')} ${':cursor'}
${s.sqlCond(true, s.sql`AND ${s.sqlCond(false, '1=1', '0=0')}`)}
`
)}
Expand Down

0 comments on commit 96aa155

Please sign in to comment.