tommybananas / finale

Create flexible REST endpoints and controllers from Sequelize models in your Express app
187 stars 36 forks source link

Can't search for substrings #66

Closed glaroc closed 1 year ago

glaroc commented 4 years ago

I have a simple resource described as

  const leafSpectraResource = finale.resource({
    model: db.LeafSpectra,
    endpoints: ['leaf_spectra/', 'leaf_spectra/:id'],
    search: [
      {operator: db.Sequelize.Op.substring, param: 'scientific_name', attributes: ['scientific_name']},
    ]
  })

I have values in the table that have value 'Acer saccharum' for the scientific_name column. If I do a query with http://.../leaf_spectra/?scientific_name=Acer saccharum, I get the proper response. However, if just do http://.../leaf_spectra/?scientific_name=Acer, I get no response. I've tried with substring, iLike and no operators and I always get an empty result unless I specify the entire string. Any idea what I'm doing wrong? With latest versions of Finale and Sequelize.

glaroc commented 4 years ago

So I gather from this PR that this is an actual bug?

https://github.com/tommybananas/finale/pull/40

RRozza commented 1 year ago

Solved here