Skip to content

Problems with filter since latest version #9

@adnanoner

Description

@adnanoner

Hi there,

I'm having some troubles with the new filters added in the latest version. I'm using it in

  const requestData = JsonApiQueryParser.parseRequest(req.url);
  requestData.require = true;
  requestData.withRelated = requestData.queryData.include;
  console.log(requestData);
  new User()
  .fetchJsonApi(requestData.queryData)
  .then((users) => {
    console.log(users);
    const data = mapper.map(users, 'users');
    res.status(200).json(data);
  })
  .catch((error) => {
    console.error(error);
  })

When I just do a request to /users/ the result of requestData is

{ resourceType: 'users',
  identifier: null,
  relationships: false,
  relationshipType: null,
  queryData:
   { include: [],
     fields: {},
     sort: [],
     page: {},
     filter: { like: {}, not: {}, lt: {}, lte: {}, gt: {}, gte: {} } },
  require: true,
  withRelated: [] }

MySQL gives a parse error

Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') and `not` in () and `lt` in () and `lte` in () and `gt` in () and `gte` in ()' at line 1```

When I delete all the filter keys from the requestData.filter object the problem is solved. I don't have this problem when I'm querying with a specific id, the problem does not occur. Any clue what is going wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions