Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update [email protected] #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "egg-mysql",
"version": "4.0.0",
"version": "4.1.0",
"description": "MySQL plugin for egg",
"eggPlugin": {
"name": "mysql"
Expand All @@ -20,7 +20,7 @@
"database"
],
"dependencies": {
"ali-rds": "^5.1.2"
"ali-rds": "^6.4.0"
},
"devDependencies": {
"@eggjs/tsconfig": "^1.3.2",
Expand Down
11 changes: 10 additions & 1 deletion test/mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ describe('test/mysql.test.ts', () => {
assert(row.id === user.id);
});

it('should query with literal in where conditions', async () => {
const user = await app.mysql.queryOne('select * from npm_auth where `password` is not NULL');
assert(user);
assert(typeof user.user_id === 'string' && user.user_id);

const row = await app.mysql.get('npm_auth', { password: new app.mysql.literals.Literal('is not NULL') });
assert(row.id === user.id);
});

it('should query one not exists return null', async () => {
let user = await app.mysql.queryOne('select * from npm_auth where id = -1');
assert(!user);
Expand Down Expand Up @@ -119,7 +128,7 @@ describe('test/mysql.test.ts', () => {
const result = await app.mysql.beginTransactionScope(async conn => {
const row = await conn.queryOne('select * from npm_auth order by id desc limit 10');
return { row };
}, {});
});
assert(result.row);
assert(result.row.user_id && typeof result.row.user_id === 'string');
assert(result.row.password === '3');
Expand Down