Skip to content

Commit

Permalink
Merge 41cd393 into 9b8cfca
Browse files Browse the repository at this point in the history
  • Loading branch information
naxmefy committed Sep 23, 2020
2 parents 9b8cfca + 41cd393 commit a9efbe7
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 83 deletions.
17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ env:
- NODE_VERSION=10
- NODE_VERSION=11
- NODE_VERSION=12
- NODE_VERSION=14
cache:
directories:
- node_modules
- node_modules
before_install:
- nvm install $NODE_VERSION
- node --version
- python --version
- nvm install $NODE_VERSION
- node --version
- python --version
install:
- npm install
- npm install -g coveralls nyc
- npm install
- npm install -g coveralls nyc
script:
- npm run test:coverage
- npm run test:coverage
after_success:
- nyc report --reporter=text-lcov | coveralls
- nyc report --reporter=text-lcov | coveralls
notifications:
email:
on_success: never
Expand Down
119 changes: 49 additions & 70 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
"@types/mocha": "^2.2.41",
"@types/should": "^8.3.0",
"co-mocha": "^1.2.0",
"java": "^0.12.0",
"java": "^0.12.1",
"mocha": "^6.2.2",
"node-java-maven": "^0.0.12",
"node-java-maven": "^0.1.2",
"nyc": "^14.1.1",
"should": "^11.2.1",
"ts-node": "^3.0.4",
Expand All @@ -80,9 +80,9 @@
"lodash": "^4.17.4"
},
"peerDependencies": {
"java": "^0.12.0"
"java": "^0.12.1"
},
"optionalDependencies": {
"node-java-maven": "^0.0.12"
"node-java-maven": "^0.1.2"
}
}
7 changes: 6 additions & 1 deletion src/Statement.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Promise from 'bluebird'

import { IResultSet, ResultSet } from './ResultSet'

export interface IStatement {
Expand All @@ -19,7 +20,11 @@ export class Statement {
protected statement: IStatement

constructor (statement) {
this.statement = Promise.promisifyAll(statement) as IStatement
this.statement = Promise.promisifyAll(statement, {
filter: (name, _, __, passesDefaultFilter) => {
return passesDefaultFilter && !name.endsWith('Async')
}
}) as IStatement
}

executeUpdate (sql: string): Promise<number> {
Expand Down
29 changes: 29 additions & 0 deletions test/JDBC.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,33 @@ describe('JDBC', () => {
should.exist(connection)
})
})

it('should create and execute a statement', async () => {
const jdbc = new JDBC({
className: 'org.h2.Driver',
url: 'jdbc:h2:mem:test'
})

const statement = await jdbc.createStatement()
await statement.executeUpdate(`
CREATE TABLE jdbc_test_table (
id int not null
)
`)

const result = await statement.executeUpdate(`
INSERT INTO jdbc_test_table (id) VALUES
(1),
(2)
`)

result.should.be.equal(2)

const result2 = await statement.executeQuery(`
SELECT * FROM jdbc_test_table
`)

const resultSet = result2.fetchAllResults()
resultSet.should.have.length(2)
})
})

0 comments on commit a9efbe7

Please sign in to comment.