Comparing version 0.0.9 to 0.0.10
@@ -38,3 +38,9 @@ const mysql = require('../mysql') | ||
} else { | ||
conditions.push(`${key} in ( ${mysql.escape(this.conditions['select'][key]) } )`) | ||
if (/_not_like$/.test(key)) { | ||
conditions.push(`${key.split('_not_like')[0]} not like ${mysql.escape(this.conditions['select'][key])}`) | ||
} else if (/_like$/.test(key)) { | ||
conditions.push(`${key.split('_like')[0]} like ${mysql.escape(this.conditions['select'][key])}`) | ||
} else { | ||
conditions.push(`${key} in ( ${mysql.escape(this.conditions['select'][key]) } )`) | ||
} | ||
} | ||
@@ -41,0 +47,0 @@ } |
{ | ||
"name": "h-orm", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/yuanhaoyu/h-orm.git", |
@@ -37,2 +37,3 @@ const horm = require('../../index') | ||
}); | ||
test('where {sex: 0}', async () => { | ||
@@ -43,2 +44,3 @@ expect(await StudentModel().where({ sex: 0 })).toEqual([ | ||
}) | ||
test('where {sex: 0}', async () => { | ||
@@ -51,2 +53,15 @@ expect(await StudentModel().where({ sex: ['0', '1'] })).toEqual([ | ||
}) | ||
test('where {sex: 0} and name like ad', async () => { | ||
expect(await StudentModel().where({ sex: 1, name_like: '%ad%' })).toEqual([ | ||
{ name: 'adad', sex: 1 }, | ||
]) | ||
}) | ||
test('where {sex: 0} and name not like ad', async () => { | ||
expect(await StudentModel().where({ sex: 1, name_not_like: '%ad%' })).toEqual([ | ||
{ name: 'man', sex: 1 }, | ||
]) | ||
}) | ||
test('where {sex: 0} or {sex: 1}', async () => { | ||
@@ -58,4 +73,5 @@ expect(await StudentModel().where({ sex: 0, name: 'man' }, 'OR')).toEqual([ | ||
}) | ||
test('close mysql here', () => { | ||
mysql.close() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22819
589