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

MSSQL delete with string id: Undefined binding(s) detected #3558

Open
mades5 opened this issue Jan 5, 2025 · 0 comments
Open

MSSQL delete with string id: Undefined binding(s) detected #3558

mades5 opened this issue Jan 5, 2025 · 0 comments

Comments

@mades5
Copy link

mades5 commented Jan 5, 2025

Steps to reproduce

created a fresh application with existing mssql database. Created a model via cli

// // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
import { resolve } from '@feathersjs/schema'
import { Type, getValidator, querySyntax } from '@feathersjs/typebox'
import type { Static } from '@feathersjs/typebox'

import type { HookContext } from '../../declarations'
import { dataValidator, queryValidator } from '../../validators'
import type { ObjectsService } from './objects.class'

// Main data model schema
export const objectsSchema = Type.Object(
  {
    id: Type.String(),
    field: Type.String()
  },
  { $id: 'Objects', additionalProperties: true }
)
export type Objects = Static<typeof objectsSchema>
export const objectsValidator = getValidator(objectsSchema, dataValidator)
export const objectsResolver = resolve<Objects, HookContext<ObjectsService>>({})

export const objectsExternalResolver = resolve<Objects, HookContext<ObjectsService>>({})

// Schema for creating new entries
export const objectsDataSchema = Type.Pick(objectsSchema, ['field'], {
  $id: 'ObjectsData'
})
export type ObjectsData = Static<typeof objectsDataSchema>
export const objectsDataValidator = getValidator(objectsDataSchema, dataValidator)
export const objectsDataResolver = resolve<Objects, HookContext<ObjectsService>>({})

// Schema for updating existing entries
export const objectsPatchSchema = Type.Partial(objectsSchema, {
  $id: 'ObjectsPatch'
})
export type ObjectsPatch = Static<typeof objectsPatchSchema>
export const objectsPatchValidator = getValidator(objectsPatchSchema, dataValidator)
export const objectsPatchResolver = resolve<Objects, HookContext<ObjectsService>>({})

// Schema for allowed query properties
export const objectsQueryProperties = Type.Pick(objectsSchema, ['id', 'field'])
export const objectsQuerySchema = Type.Intersect(
  [
    querySyntax(objectsQueryProperties),
    // Add additional query properties here
    Type.Object({}, { additionalProperties: false })
  ],
  { additionalProperties: false }
)
export type ObjectsQuery = Static<typeof objectsQuerySchema>
export const objectsQueryValidator = getValidator(objectsQuerySchema, queryValidator)
export const objectsQueryResolver = resolve<ObjectsQuery, HookContext<ObjectsService>>({})

Expected behavior

curl -X DELETE http://localhost:3030/objects/my_id should delete the record

Actual behavior

error: GeneralError: Undefined binding(s) detected when compiling DEL. Undefined column(s): [id] query: delete from [table_name] where [id] in (?);select @@rowcount

curl -X GET http://localhost:3030/objects/my_id gives json as result

curl -X GET http://localhost:3030/objects/ gives all results from database

also post and patch works, just delete gives that error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant