mirror of
https://github.com/knex/knex.git
synced 2025-12-27 15:08:47 +00:00
tests for escaping single-quotes
This commit is contained in:
parent
56d808fe0a
commit
332ed3b811
@ -29,7 +29,7 @@ function qb() {
|
||||
return clients.default.queryBuilder()
|
||||
}
|
||||
|
||||
function raw(sql, bindings) {
|
||||
function raw(sql, bindings) {
|
||||
return clients.default.raw(sql, bindings)
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ function verifySqlResult(dialect, expectedObj, sqlObj) {
|
||||
expectedObj[key](sqlObj[key]);
|
||||
} else {
|
||||
try {
|
||||
expect(sqlObj[key]).to.deep.equal(expectedObj[key]);
|
||||
expect(sqlObj[key]).to.deep.equal(expectedObj[key]);
|
||||
} catch (e) {
|
||||
e.stack = dialect + ': ' + e.stack
|
||||
throw e
|
||||
@ -2489,6 +2489,13 @@ describe("QueryBuilder", function() {
|
||||
})
|
||||
})
|
||||
|
||||
it("escapes single quotes properly", function() {
|
||||
testquery(qb().select('*').from('users').where('last_name', 'O\'Brien'), {
|
||||
postgres: 'select * from "users" where "last_name" = \'O\'\'Brien\'',
|
||||
default: 'select * from "users" where "last_name" = \'O\\\'Brien\'',
|
||||
});
|
||||
});
|
||||
|
||||
it("allows join without operator and with value 0 #953", function() {
|
||||
testsql(qb().select('*').from('users').join('photos', 'photos.id', 0), {
|
||||
mysql: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user