Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ class SequelizeQueryStringParser {
*/
find (expression) {
let where = {}
if (expression.match(/(([\w|.]+)\s(\w+)\s([\w|\s|%|_]+),?)+/)) {
let parts = (expression).split(',')
if (expression.match(new RegExp(`(([\\w|.]+)\\s(\\w+)\\s([\\w|\\s|%|_|${utf8letters}]+),?)+`))) {
let parts = (expression).split(/,\s/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to force a space after a condition separation?

const operators = this.operators()
for (let i = 0; i < parts.length; i++) {
// build a regexp to match filter expressions
const lhs = '[\\w|.]+'
const op = '\\w+'
const rhs = `[A-Za-z0-9.+@:/()%_\\s\\-\\xAA\\xB5\\xBA${utf8letters}]+`
const rhs = `.+`
const expressionRegExp = new RegExp(`(${lhs})\\s+(${op})\\s+(${rhs})`)
if (parts[i].match(expressionRegExp)) {
let prop = RegExp.$1
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sequelize-querystring",
"version": "0.10.0",
"name": "sequelize-querystring-utf8",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to change the package name?

"version": "0.10.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to increase the version to 0.11.0

"description": "Convert the request query string into sequelize compatible where and sort clauses.",
"main": "index.js",
"engines": {
Expand Down
12 changes: 12 additions & 0 deletions test/test_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ const sqs = require('../index.js')


describe('Convert query strings into Sequelize find queries.', (done) => {
it('(eq) Find convert equal operator with utf8letter to where.', () => {
let qs = 'geoId eq 测试'
let where = sqs.find(qs)
expect(where).to.be.instanceof(Object)
expect(where).to.have.deep.property('geoId.$eq', '测试')
// test symbolic
where = sqsSym.find(qs)
expect(where).to.be.instanceof(Object)
expect(where).to.have.property('geoId')
expect(where.geoId).to.have.property(sequelize.Op.eq, '测试')
})

// test string, integer and UUID
it('(eq) Find convert equal operator to where.', () => {
let qs = 'geoId eq 4301'
Expand Down