Coder Social home page Coder Social logo

Comments (6)

mbroadst avatar mbroadst commented on September 27, 2024

@treefort you're right, and I thought I could just change "like" to "$iLike" here, but it fails on a few tests. Unfortunately that's about all the time I have these day 😄, any interest in trying to figure this one out? PRs are gladly welcomed

from epilogue.

treefort avatar treefort commented on September 27, 2024

The operator could be passed in has an optional attribute in the search options. ex:

var users = rest.resource({
    model: User,
    endpoints: ['/users', '/users/:id'],
    search: {
      param: 'searchOnlyUsernames',
      attributes: [ 'username' ],
      operator: '$iLike'    // (defaults to 'like'
    }
});

It's not pretty, but it'd work... plus it wouldn't mess up existing implementations. I can put it in a PR with corresponding tests and stuff, but I wanted to get your thoughts first.

from epilogue.

mbroadst avatar mbroadst commented on September 27, 2024

@treefort I wouldn't be against it, but we should also conform with the docs right? (as in default to iLike). I know this seems sinfully lazy, but I can't even recall what tests broke - did you take a look?

from epilogue.

treefort avatar treefort commented on September 27, 2024

Basically, any test that uses a substring match failed. If I'm understanding this correctly, sequelize isn't guarding against the fact that iLike is only supported in pg... so it seems like a strange default. Here's how I tested:

User.findAll({where: { username: {$iLike: "%e%"}}})

which resulted in...

Unhandled rejection SequelizeDatabaseError: SQLITE_ERROR: near "ILIKE": syntax error

from epilogue.

mbroadst avatar mbroadst commented on September 27, 2024

aah yeah of course, and mysql does case insensitive searches by default as well as sqlite. Yeah okay, please go ahead and add the operator for pg!

from epilogue.

treefort avatar treefort commented on September 27, 2024

Awesome. Addressed with #78.

from epilogue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.